documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076
  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. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** 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 */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** 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 */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** 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 */
  684. static readonly GEQUAL: number;
  685. /** 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 */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * 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.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * 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.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. 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>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. 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;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): 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. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result 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. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" 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. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal 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 Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  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. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal 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 Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" 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. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  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 FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared 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 squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  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. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5780. * @returns a string containing the hexadecimal representation of the Color4 object
  5781. */
  5782. toHexString(returnAsColor3?: boolean): string;
  5783. /**
  5784. * Computes a new Color4 converted from the current one to linear space
  5785. * @returns a new Color4 object
  5786. */
  5787. toLinearSpace(): Color4;
  5788. /**
  5789. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5790. * @param convertedColor defines the Color4 object where to store the linear space version
  5791. * @returns the unmodified Color4
  5792. */
  5793. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5794. /**
  5795. * Computes a new Color4 converted from the current one to gamma space
  5796. * @returns a new Color4 object
  5797. */
  5798. toGammaSpace(): Color4;
  5799. /**
  5800. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5801. * @param convertedColor defines the Color4 object where to store the gamma space version
  5802. * @returns the unmodified Color4
  5803. */
  5804. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5805. /**
  5806. * Creates a new Color4 from the string containing valid hexadecimal values
  5807. * @param hex defines a string containing valid hexadecimal values
  5808. * @returns a new Color4 object
  5809. */
  5810. static FromHexString(hex: string): Color4;
  5811. /**
  5812. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5813. * @param left defines the start value
  5814. * @param right defines the end value
  5815. * @param amount defines the gradient factor
  5816. * @returns a new Color4 object
  5817. */
  5818. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5819. /**
  5820. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5821. * @param left defines the start value
  5822. * @param right defines the end value
  5823. * @param amount defines the gradient factor
  5824. * @param result defines the Color4 object where to store data
  5825. */
  5826. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5827. /**
  5828. * Creates a new Color4 from a Color3 and an alpha value
  5829. * @param color3 defines the source Color3 to read from
  5830. * @param alpha defines the alpha component (1.0 by default)
  5831. * @returns a new Color4 object
  5832. */
  5833. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5834. /**
  5835. * Creates a new Color4 from the starting index element of the given array
  5836. * @param array defines the source array to read from
  5837. * @param offset defines the offset in the source array
  5838. * @returns a new Color4 object
  5839. */
  5840. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5841. /**
  5842. * Creates a new Color3 from integer values (< 256)
  5843. * @param r defines the red component to read from (value between 0 and 255)
  5844. * @param g defines the green component to read from (value between 0 and 255)
  5845. * @param b defines the blue component to read from (value between 0 and 255)
  5846. * @param a defines the alpha component to read from (value between 0 and 255)
  5847. * @returns a new Color3 object
  5848. */
  5849. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5850. /**
  5851. * Check the content of a given array and convert it to an array containing RGBA data
  5852. * If the original array was already containing count * 4 values then it is returned directly
  5853. * @param colors defines the array to check
  5854. * @param count defines the number of RGBA data to expect
  5855. * @returns an array containing count * 4 values (RGBA)
  5856. */
  5857. static CheckColors4(colors: number[], count: number): number[];
  5858. }
  5859. /**
  5860. * @hidden
  5861. */
  5862. export class TmpColors {
  5863. static Color3: Color3[];
  5864. static Color4: Color4[];
  5865. }
  5866. }
  5867. declare module BABYLON {
  5868. /**
  5869. * Defines an interface which represents an animation key frame
  5870. */
  5871. export interface IAnimationKey {
  5872. /**
  5873. * Frame of the key frame
  5874. */
  5875. frame: number;
  5876. /**
  5877. * Value at the specifies key frame
  5878. */
  5879. value: any;
  5880. /**
  5881. * The input tangent for the cubic hermite spline
  5882. */
  5883. inTangent?: any;
  5884. /**
  5885. * The output tangent for the cubic hermite spline
  5886. */
  5887. outTangent?: any;
  5888. /**
  5889. * The animation interpolation type
  5890. */
  5891. interpolation?: AnimationKeyInterpolation;
  5892. }
  5893. /**
  5894. * Enum for the animation key frame interpolation type
  5895. */
  5896. export enum AnimationKeyInterpolation {
  5897. /**
  5898. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5899. */
  5900. STEP = 1
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. /**
  5905. * Represents the range of an animation
  5906. */
  5907. export class AnimationRange {
  5908. /**The name of the animation range**/
  5909. name: string;
  5910. /**The starting frame of the animation */
  5911. from: number;
  5912. /**The ending frame of the animation*/
  5913. to: number;
  5914. /**
  5915. * Initializes the range of an animation
  5916. * @param name The name of the animation range
  5917. * @param from The starting frame of the animation
  5918. * @param to The ending frame of the animation
  5919. */
  5920. constructor(
  5921. /**The name of the animation range**/
  5922. name: string,
  5923. /**The starting frame of the animation */
  5924. from: number,
  5925. /**The ending frame of the animation*/
  5926. to: number);
  5927. /**
  5928. * Makes a copy of the animation range
  5929. * @returns A copy of the animation range
  5930. */
  5931. clone(): AnimationRange;
  5932. }
  5933. }
  5934. declare module BABYLON {
  5935. /**
  5936. * Composed of a frame, and an action function
  5937. */
  5938. export class AnimationEvent {
  5939. /** The frame for which the event is triggered **/
  5940. frame: number;
  5941. /** The event to perform when triggered **/
  5942. action: (currentFrame: number) => void;
  5943. /** Specifies if the event should be triggered only once**/
  5944. onlyOnce?: boolean | undefined;
  5945. /**
  5946. * Specifies if the animation event is done
  5947. */
  5948. isDone: boolean;
  5949. /**
  5950. * Initializes the animation event
  5951. * @param frame The frame for which the event is triggered
  5952. * @param action The event to perform when triggered
  5953. * @param onlyOnce Specifies if the event should be triggered only once
  5954. */
  5955. constructor(
  5956. /** The frame for which the event is triggered **/
  5957. frame: number,
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void,
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined);
  5962. /** @hidden */
  5963. _clone(): AnimationEvent;
  5964. }
  5965. }
  5966. declare module BABYLON {
  5967. /**
  5968. * Interface used to define a behavior
  5969. */
  5970. export interface Behavior<T> {
  5971. /** gets or sets behavior's name */
  5972. name: string;
  5973. /**
  5974. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5975. */
  5976. init(): void;
  5977. /**
  5978. * Called when the behavior is attached to a target
  5979. * @param target defines the target where the behavior is attached to
  5980. */
  5981. attach(target: T): void;
  5982. /**
  5983. * Called when the behavior is detached from its target
  5984. */
  5985. detach(): void;
  5986. }
  5987. /**
  5988. * Interface implemented by classes supporting behaviors
  5989. */
  5990. export interface IBehaviorAware<T> {
  5991. /**
  5992. * Attach a behavior
  5993. * @param behavior defines the behavior to attach
  5994. * @returns the current host
  5995. */
  5996. addBehavior(behavior: Behavior<T>): T;
  5997. /**
  5998. * Remove a behavior from the current object
  5999. * @param behavior defines the behavior to detach
  6000. * @returns the current host
  6001. */
  6002. removeBehavior(behavior: Behavior<T>): T;
  6003. /**
  6004. * Gets a behavior using its name to search
  6005. * @param name defines the name to search
  6006. * @returns the behavior or null if not found
  6007. */
  6008. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * Defines an array and its length.
  6014. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6015. */
  6016. export interface ISmartArrayLike<T> {
  6017. /**
  6018. * The data of the array.
  6019. */
  6020. data: Array<T>;
  6021. /**
  6022. * The active length of the array.
  6023. */
  6024. length: number;
  6025. }
  6026. /**
  6027. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6028. */
  6029. export class SmartArray<T> implements ISmartArrayLike<T> {
  6030. /**
  6031. * The full set of data from the array.
  6032. */
  6033. data: Array<T>;
  6034. /**
  6035. * The active length of the array.
  6036. */
  6037. length: number;
  6038. protected _id: number;
  6039. /**
  6040. * Instantiates a Smart Array.
  6041. * @param capacity defines the default capacity of the array.
  6042. */
  6043. constructor(capacity: number);
  6044. /**
  6045. * Pushes a value at the end of the active data.
  6046. * @param value defines the object to push in the array.
  6047. */
  6048. push(value: T): void;
  6049. /**
  6050. * Iterates over the active data and apply the lambda to them.
  6051. * @param func defines the action to apply on each value.
  6052. */
  6053. forEach(func: (content: T) => void): void;
  6054. /**
  6055. * Sorts the full sets of data.
  6056. * @param compareFn defines the comparison function to apply.
  6057. */
  6058. sort(compareFn: (a: T, b: T) => number): void;
  6059. /**
  6060. * Resets the active data to an empty array.
  6061. */
  6062. reset(): void;
  6063. /**
  6064. * Releases all the data from the array as well as the array.
  6065. */
  6066. dispose(): void;
  6067. /**
  6068. * Concats the active data with a given array.
  6069. * @param array defines the data to concatenate with.
  6070. */
  6071. concat(array: any): void;
  6072. /**
  6073. * Returns the position of a value in the active data.
  6074. * @param value defines the value to find the index for
  6075. * @returns the index if found in the active data otherwise -1
  6076. */
  6077. indexOf(value: T): number;
  6078. /**
  6079. * Returns whether an element is part of the active data.
  6080. * @param value defines the value to look for
  6081. * @returns true if found in the active data otherwise false
  6082. */
  6083. contains(value: T): boolean;
  6084. private static _GlobalId;
  6085. }
  6086. /**
  6087. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6088. * The data in this array can only be present once
  6089. */
  6090. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6091. private _duplicateId;
  6092. /**
  6093. * Pushes a value at the end of the active data.
  6094. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6095. * @param value defines the object to push in the array.
  6096. */
  6097. push(value: T): void;
  6098. /**
  6099. * Pushes a value at the end of the active data.
  6100. * If the data is already present, it won t be added again
  6101. * @param value defines the object to push in the array.
  6102. * @returns true if added false if it was already present
  6103. */
  6104. pushNoDuplicate(value: T): boolean;
  6105. /**
  6106. * Resets the active data to an empty array.
  6107. */
  6108. reset(): void;
  6109. /**
  6110. * Concats the active data with a given array.
  6111. * This ensures no dupplicate will be present in the result.
  6112. * @param array defines the data to concatenate with.
  6113. */
  6114. concatWithNoDuplicate(array: any): void;
  6115. }
  6116. }
  6117. declare module BABYLON {
  6118. /**
  6119. * @ignore
  6120. * This is a list of all the different input types that are available in the application.
  6121. * Fo instance: ArcRotateCameraGamepadInput...
  6122. */
  6123. export var CameraInputTypes: {};
  6124. /**
  6125. * This is the contract to implement in order to create a new input class.
  6126. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6127. */
  6128. export interface ICameraInput<TCamera extends Camera> {
  6129. /**
  6130. * Defines the camera the input is attached to.
  6131. */
  6132. camera: Nullable<TCamera>;
  6133. /**
  6134. * Gets the class name of the current intput.
  6135. * @returns the class name
  6136. */
  6137. getClassName(): string;
  6138. /**
  6139. * Get the friendly name associated with the input class.
  6140. * @returns the input friendly name
  6141. */
  6142. getSimpleName(): string;
  6143. /**
  6144. * Attach the input controls to a specific dom element to get the input from.
  6145. * @param element Defines the element the controls should be listened from
  6146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6147. */
  6148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6149. /**
  6150. * Detach the current controls from the specified dom element.
  6151. * @param element Defines the element to stop listening the inputs from
  6152. */
  6153. detachControl(element: Nullable<HTMLElement>): void;
  6154. /**
  6155. * Update the current camera state depending on the inputs that have been used this frame.
  6156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6157. */
  6158. checkInputs?: () => void;
  6159. }
  6160. /**
  6161. * Represents a map of input types to input instance or input index to input instance.
  6162. */
  6163. export interface CameraInputsMap<TCamera extends Camera> {
  6164. /**
  6165. * Accessor to the input by input type.
  6166. */
  6167. [name: string]: ICameraInput<TCamera>;
  6168. /**
  6169. * Accessor to the input by input index.
  6170. */
  6171. [idx: number]: ICameraInput<TCamera>;
  6172. }
  6173. /**
  6174. * This represents the input manager used within a camera.
  6175. * It helps dealing with all the different kind of input attached to a camera.
  6176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6177. */
  6178. export class CameraInputsManager<TCamera extends Camera> {
  6179. /**
  6180. * Defines the list of inputs attahed to the camera.
  6181. */
  6182. attached: CameraInputsMap<TCamera>;
  6183. /**
  6184. * Defines the dom element the camera is collecting inputs from.
  6185. * This is null if the controls have not been attached.
  6186. */
  6187. attachedElement: Nullable<HTMLElement>;
  6188. /**
  6189. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. noPreventDefault: boolean;
  6192. /**
  6193. * Defined the camera the input manager belongs to.
  6194. */
  6195. camera: TCamera;
  6196. /**
  6197. * Update the current camera state depending on the inputs that have been used this frame.
  6198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6199. */
  6200. checkInputs: () => void;
  6201. /**
  6202. * Instantiate a new Camera Input Manager.
  6203. * @param camera Defines the camera the input manager blongs to
  6204. */
  6205. constructor(camera: TCamera);
  6206. /**
  6207. * Add an input method to a camera
  6208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6209. * @param input camera input method
  6210. */
  6211. add(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Remove a specific input method from a camera
  6214. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6215. * @param inputToRemove camera input method
  6216. */
  6217. remove(inputToRemove: ICameraInput<TCamera>): void;
  6218. /**
  6219. * Remove a specific input type from a camera
  6220. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6221. * @param inputType the type of the input to remove
  6222. */
  6223. removeByType(inputType: string): void;
  6224. private _addCheckInputs;
  6225. /**
  6226. * Attach the input controls to the currently attached dom element to listen the events from.
  6227. * @param input Defines the input to attach
  6228. */
  6229. attachInput(input: ICameraInput<TCamera>): void;
  6230. /**
  6231. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6232. * @param element Defines the dom element to collect the events from
  6233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6234. */
  6235. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6236. /**
  6237. * Detach the current manager inputs controls from a specific dom element.
  6238. * @param element Defines the dom element to collect the events from
  6239. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6240. */
  6241. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6242. /**
  6243. * Rebuild the dynamic inputCheck function from the current list of
  6244. * defined inputs in the manager.
  6245. */
  6246. rebuildInputCheck(): void;
  6247. /**
  6248. * Remove all attached input methods from a camera
  6249. */
  6250. clear(): void;
  6251. /**
  6252. * Serialize the current input manager attached to a camera.
  6253. * This ensures than once parsed,
  6254. * the input associated to the camera will be identical to the current ones
  6255. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6256. */
  6257. serialize(serializedCamera: any): void;
  6258. /**
  6259. * Parses an input manager serialized JSON to restore the previous list of inputs
  6260. * and states associated to a camera.
  6261. * @param parsedCamera Defines the JSON to parse
  6262. */
  6263. parse(parsedCamera: any): void;
  6264. }
  6265. }
  6266. declare module BABYLON {
  6267. /**
  6268. * Class used to store data that will be store in GPU memory
  6269. */
  6270. export class Buffer {
  6271. private _engine;
  6272. private _buffer;
  6273. /** @hidden */
  6274. _data: Nullable<DataArray>;
  6275. private _updatable;
  6276. private _instanced;
  6277. private _divisor;
  6278. /**
  6279. * Gets the byte stride.
  6280. */
  6281. readonly byteStride: number;
  6282. /**
  6283. * Constructor
  6284. * @param engine the engine
  6285. * @param data the data to use for this buffer
  6286. * @param updatable whether the data is updatable
  6287. * @param stride the stride (optional)
  6288. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6289. * @param instanced whether the buffer is instanced (optional)
  6290. * @param useBytes set to true if the stride in in bytes (optional)
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. */
  6293. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6294. /**
  6295. * Create a new VertexBuffer based on the current buffer
  6296. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6297. * @param offset defines offset in the buffer (0 by default)
  6298. * @param size defines the size in floats of attributes (position is 3 for instance)
  6299. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6300. * @param instanced defines if the vertex buffer contains indexed data
  6301. * @param useBytes defines if the offset and stride are in bytes *
  6302. * @param divisor sets an optional divisor for instances (1 by default)
  6303. * @returns the new vertex buffer
  6304. */
  6305. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6306. /**
  6307. * Gets a boolean indicating if the Buffer is updatable?
  6308. * @returns true if the buffer is updatable
  6309. */
  6310. isUpdatable(): boolean;
  6311. /**
  6312. * Gets current buffer's data
  6313. * @returns a DataArray or null
  6314. */
  6315. getData(): Nullable<DataArray>;
  6316. /**
  6317. * Gets underlying native buffer
  6318. * @returns underlying native buffer
  6319. */
  6320. getBuffer(): Nullable<DataBuffer>;
  6321. /**
  6322. * Gets the stride in float32 units (i.e. byte stride / 4).
  6323. * May not be an integer if the byte stride is not divisible by 4.
  6324. * @returns the stride in float32 units
  6325. * @deprecated Please use byteStride instead.
  6326. */
  6327. getStrideSize(): number;
  6328. /**
  6329. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6330. * @param data defines the data to store
  6331. */
  6332. create(data?: Nullable<DataArray>): void;
  6333. /** @hidden */
  6334. _rebuild(): void;
  6335. /**
  6336. * Update current buffer data
  6337. * @param data defines the data to store
  6338. */
  6339. update(data: DataArray): void;
  6340. /**
  6341. * Updates the data directly.
  6342. * @param data the new data
  6343. * @param offset the new offset
  6344. * @param vertexCount the vertex count (optional)
  6345. * @param useBytes set to true if the offset is in bytes
  6346. */
  6347. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6348. /**
  6349. * Release all resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. /**
  6354. * Specialized buffer used to store vertex data
  6355. */
  6356. export class VertexBuffer {
  6357. /** @hidden */
  6358. _buffer: Buffer;
  6359. private _kind;
  6360. private _size;
  6361. private _ownsBuffer;
  6362. private _instanced;
  6363. private _instanceDivisor;
  6364. /**
  6365. * The byte type.
  6366. */
  6367. static readonly BYTE: number;
  6368. /**
  6369. * The unsigned byte type.
  6370. */
  6371. static readonly UNSIGNED_BYTE: number;
  6372. /**
  6373. * The short type.
  6374. */
  6375. static readonly SHORT: number;
  6376. /**
  6377. * The unsigned short type.
  6378. */
  6379. static readonly UNSIGNED_SHORT: number;
  6380. /**
  6381. * The integer type.
  6382. */
  6383. static readonly INT: number;
  6384. /**
  6385. * The unsigned integer type.
  6386. */
  6387. static readonly UNSIGNED_INT: number;
  6388. /**
  6389. * The float type.
  6390. */
  6391. static readonly FLOAT: number;
  6392. /**
  6393. * Gets or sets the instance divisor when in instanced mode
  6394. */
  6395. get instanceDivisor(): number;
  6396. set instanceDivisor(value: number);
  6397. /**
  6398. * Gets the byte stride.
  6399. */
  6400. readonly byteStride: number;
  6401. /**
  6402. * Gets the byte offset.
  6403. */
  6404. readonly byteOffset: number;
  6405. /**
  6406. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6407. */
  6408. readonly normalized: boolean;
  6409. /**
  6410. * Gets the data type of each component in the array.
  6411. */
  6412. readonly type: number;
  6413. /**
  6414. * Constructor
  6415. * @param engine the engine
  6416. * @param data the data to use for this vertex buffer
  6417. * @param kind the vertex buffer kind
  6418. * @param updatable whether the data is updatable
  6419. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6420. * @param stride the stride (optional)
  6421. * @param instanced whether the buffer is instanced (optional)
  6422. * @param offset the offset of the data (optional)
  6423. * @param size the number of components (optional)
  6424. * @param type the type of the component (optional)
  6425. * @param normalized whether the data contains normalized data (optional)
  6426. * @param useBytes set to true if stride and offset are in bytes (optional)
  6427. * @param divisor defines the instance divisor to use (1 by default)
  6428. */
  6429. 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);
  6430. /** @hidden */
  6431. _rebuild(): void;
  6432. /**
  6433. * Returns the kind of the VertexBuffer (string)
  6434. * @returns a string
  6435. */
  6436. getKind(): string;
  6437. /**
  6438. * Gets a boolean indicating if the VertexBuffer is updatable?
  6439. * @returns true if the buffer is updatable
  6440. */
  6441. isUpdatable(): boolean;
  6442. /**
  6443. * Gets current buffer's data
  6444. * @returns a DataArray or null
  6445. */
  6446. getData(): Nullable<DataArray>;
  6447. /**
  6448. * Gets underlying native buffer
  6449. * @returns underlying native buffer
  6450. */
  6451. getBuffer(): Nullable<DataBuffer>;
  6452. /**
  6453. * Gets the stride in float32 units (i.e. byte stride / 4).
  6454. * May not be an integer if the byte stride is not divisible by 4.
  6455. * @returns the stride in float32 units
  6456. * @deprecated Please use byteStride instead.
  6457. */
  6458. getStrideSize(): number;
  6459. /**
  6460. * Returns the offset as a multiple of the type byte length.
  6461. * @returns the offset in bytes
  6462. * @deprecated Please use byteOffset instead.
  6463. */
  6464. getOffset(): number;
  6465. /**
  6466. * Returns the number of components per vertex attribute (integer)
  6467. * @returns the size in float
  6468. */
  6469. getSize(): number;
  6470. /**
  6471. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6472. * @returns true if this buffer is instanced
  6473. */
  6474. getIsInstanced(): boolean;
  6475. /**
  6476. * Returns the instancing divisor, zero for non-instanced (integer).
  6477. * @returns a number
  6478. */
  6479. getInstanceDivisor(): number;
  6480. /**
  6481. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6482. * @param data defines the data to store
  6483. */
  6484. create(data?: DataArray): void;
  6485. /**
  6486. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6487. * This function will create a new buffer if the current one is not updatable
  6488. * @param data defines the data to store
  6489. */
  6490. update(data: DataArray): void;
  6491. /**
  6492. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6493. * Returns the directly updated WebGLBuffer.
  6494. * @param data the new data
  6495. * @param offset the new offset
  6496. * @param useBytes set to true if the offset is in bytes
  6497. */
  6498. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6499. /**
  6500. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6501. */
  6502. dispose(): void;
  6503. /**
  6504. * Enumerates each value of this vertex buffer as numbers.
  6505. * @param count the number of values to enumerate
  6506. * @param callback the callback function called for each value
  6507. */
  6508. forEach(count: number, callback: (value: number, index: number) => void): void;
  6509. /**
  6510. * Positions
  6511. */
  6512. static readonly PositionKind: string;
  6513. /**
  6514. * Normals
  6515. */
  6516. static readonly NormalKind: string;
  6517. /**
  6518. * Tangents
  6519. */
  6520. static readonly TangentKind: string;
  6521. /**
  6522. * Texture coordinates
  6523. */
  6524. static readonly UVKind: string;
  6525. /**
  6526. * Texture coordinates 2
  6527. */
  6528. static readonly UV2Kind: string;
  6529. /**
  6530. * Texture coordinates 3
  6531. */
  6532. static readonly UV3Kind: string;
  6533. /**
  6534. * Texture coordinates 4
  6535. */
  6536. static readonly UV4Kind: string;
  6537. /**
  6538. * Texture coordinates 5
  6539. */
  6540. static readonly UV5Kind: string;
  6541. /**
  6542. * Texture coordinates 6
  6543. */
  6544. static readonly UV6Kind: string;
  6545. /**
  6546. * Colors
  6547. */
  6548. static readonly ColorKind: string;
  6549. /**
  6550. * Matrix indices (for bones)
  6551. */
  6552. static readonly MatricesIndicesKind: string;
  6553. /**
  6554. * Matrix weights (for bones)
  6555. */
  6556. static readonly MatricesWeightsKind: string;
  6557. /**
  6558. * Additional matrix indices (for bones)
  6559. */
  6560. static readonly MatricesIndicesExtraKind: string;
  6561. /**
  6562. * Additional matrix weights (for bones)
  6563. */
  6564. static readonly MatricesWeightsExtraKind: string;
  6565. /**
  6566. * Deduces the stride given a kind.
  6567. * @param kind The kind string to deduce
  6568. * @returns The deduced stride
  6569. */
  6570. static DeduceStride(kind: string): number;
  6571. /**
  6572. * Gets the byte length of the given type.
  6573. * @param type the type
  6574. * @returns the number of bytes
  6575. */
  6576. static GetTypeByteLength(type: number): number;
  6577. /**
  6578. * Enumerates each value of the given parameters as numbers.
  6579. * @param data the data to enumerate
  6580. * @param byteOffset the byte offset of the data
  6581. * @param byteStride the byte stride of the data
  6582. * @param componentCount the number of components per element
  6583. * @param componentType the type of the component
  6584. * @param count the number of values to enumerate
  6585. * @param normalized whether the data is normalized
  6586. * @param callback the callback function called for each value
  6587. */
  6588. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6589. private static _GetFloatValue;
  6590. }
  6591. }
  6592. declare module BABYLON {
  6593. /**
  6594. * @hidden
  6595. */
  6596. export class IntersectionInfo {
  6597. bu: Nullable<number>;
  6598. bv: Nullable<number>;
  6599. distance: number;
  6600. faceId: number;
  6601. subMeshId: number;
  6602. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Represens a plane by the equation ax + by + cz + d = 0
  6608. */
  6609. export class Plane {
  6610. private static _TmpMatrix;
  6611. /**
  6612. * Normal of the plane (a,b,c)
  6613. */
  6614. normal: Vector3;
  6615. /**
  6616. * d component of the plane
  6617. */
  6618. d: number;
  6619. /**
  6620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6621. * @param a a component of the plane
  6622. * @param b b component of the plane
  6623. * @param c c component of the plane
  6624. * @param d d component of the plane
  6625. */
  6626. constructor(a: number, b: number, c: number, d: number);
  6627. /**
  6628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6629. */
  6630. asArray(): number[];
  6631. /**
  6632. * @returns a new plane copied from the current Plane.
  6633. */
  6634. clone(): Plane;
  6635. /**
  6636. * @returns the string "Plane".
  6637. */
  6638. getClassName(): string;
  6639. /**
  6640. * @returns the Plane hash code.
  6641. */
  6642. getHashCode(): number;
  6643. /**
  6644. * Normalize the current Plane in place.
  6645. * @returns the updated Plane.
  6646. */
  6647. normalize(): Plane;
  6648. /**
  6649. * Applies a transformation the plane and returns the result
  6650. * @param transformation the transformation matrix to be applied to the plane
  6651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6652. */
  6653. transform(transformation: DeepImmutable<Matrix>): Plane;
  6654. /**
  6655. * Calcualtte the dot product between the point and the plane normal
  6656. * @param point point to calculate the dot product with
  6657. * @returns the dot product (float) of the point coordinates and the plane normal.
  6658. */
  6659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6660. /**
  6661. * Updates the current Plane from the plane defined by the three given points.
  6662. * @param point1 one of the points used to contruct the plane
  6663. * @param point2 one of the points used to contruct the plane
  6664. * @param point3 one of the points used to contruct the plane
  6665. * @returns the updated Plane.
  6666. */
  6667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Checks if the plane is facing a given direction
  6670. * @param direction the direction to check if the plane is facing
  6671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6672. * @returns True is the vector "direction" is the same side than the plane normal.
  6673. */
  6674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6675. /**
  6676. * Calculates the distance to a point
  6677. * @param point point to calculate distance to
  6678. * @returns the signed distance (float) from the given point to the Plane.
  6679. */
  6680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6681. /**
  6682. * Creates a plane from an array
  6683. * @param array the array to create a plane from
  6684. * @returns a new Plane from the given array.
  6685. */
  6686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6687. /**
  6688. * Creates a plane from three points
  6689. * @param point1 point used to create the plane
  6690. * @param point2 point used to create the plane
  6691. * @param point3 point used to create the plane
  6692. * @returns a new Plane defined by the three given points.
  6693. */
  6694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Creates a plane from an origin point and a normal
  6697. * @param origin origin of the plane to be constructed
  6698. * @param normal normal of the plane to be constructed
  6699. * @returns a new Plane the normal vector to this plane at the given origin point.
  6700. * Note : the vector "normal" is updated because normalized.
  6701. */
  6702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6703. /**
  6704. * Calculates the distance from a plane and a point
  6705. * @param origin origin of the plane to be constructed
  6706. * @param normal normal of the plane to be constructed
  6707. * @param point point to calculate distance to
  6708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6709. */
  6710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6711. }
  6712. }
  6713. declare module BABYLON {
  6714. /**
  6715. * Class used to store bounding sphere information
  6716. */
  6717. export class BoundingSphere {
  6718. /**
  6719. * Gets the center of the bounding sphere in local space
  6720. */
  6721. readonly center: Vector3;
  6722. /**
  6723. * Radius of the bounding sphere in local space
  6724. */
  6725. radius: number;
  6726. /**
  6727. * Gets the center of the bounding sphere in world space
  6728. */
  6729. readonly centerWorld: Vector3;
  6730. /**
  6731. * Radius of the bounding sphere in world space
  6732. */
  6733. radiusWorld: number;
  6734. /**
  6735. * Gets the minimum vector in local space
  6736. */
  6737. readonly minimum: Vector3;
  6738. /**
  6739. * Gets the maximum vector in local space
  6740. */
  6741. readonly maximum: Vector3;
  6742. private _worldMatrix;
  6743. private static readonly TmpVector3;
  6744. /**
  6745. * Creates a new bounding sphere
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding sphere by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingSphere;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding sphere is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding sphere center is in between the frustum planes.
  6779. * Used for optimistic fast inclusion.
  6780. * @param frustumPlanes defines the frustum planes to test
  6781. * @returns true if the sphere center is in between the frustum planes
  6782. */
  6783. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6784. /**
  6785. * Tests if a point is inside the bounding sphere
  6786. * @param point defines the point to test
  6787. * @returns true if the point is inside the bounding sphere
  6788. */
  6789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6790. /**
  6791. * Checks if two sphere intersct
  6792. * @param sphere0 sphere 0
  6793. * @param sphere1 sphere 1
  6794. * @returns true if the speres intersect
  6795. */
  6796. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6797. }
  6798. }
  6799. declare module BABYLON {
  6800. /**
  6801. * Class used to store bounding box information
  6802. */
  6803. export class BoundingBox implements ICullable {
  6804. /**
  6805. * Gets the 8 vectors representing the bounding box in local space
  6806. */
  6807. readonly vectors: Vector3[];
  6808. /**
  6809. * Gets the center of the bounding box in local space
  6810. */
  6811. readonly center: Vector3;
  6812. /**
  6813. * Gets the center of the bounding box in world space
  6814. */
  6815. readonly centerWorld: Vector3;
  6816. /**
  6817. * Gets the extend size in local space
  6818. */
  6819. readonly extendSize: Vector3;
  6820. /**
  6821. * Gets the extend size in world space
  6822. */
  6823. readonly extendSizeWorld: Vector3;
  6824. /**
  6825. * Gets the OBB (object bounding box) directions
  6826. */
  6827. readonly directions: Vector3[];
  6828. /**
  6829. * Gets the 8 vectors representing the bounding box in world space
  6830. */
  6831. readonly vectorsWorld: Vector3[];
  6832. /**
  6833. * Gets the minimum vector in world space
  6834. */
  6835. readonly minimumWorld: Vector3;
  6836. /**
  6837. * Gets the maximum vector in world space
  6838. */
  6839. readonly maximumWorld: Vector3;
  6840. /**
  6841. * Gets the minimum vector in local space
  6842. */
  6843. readonly minimum: Vector3;
  6844. /**
  6845. * Gets the maximum vector in local space
  6846. */
  6847. readonly maximum: Vector3;
  6848. private _worldMatrix;
  6849. private static readonly TmpVector3;
  6850. /**
  6851. * @hidden
  6852. */
  6853. _tag: number;
  6854. /**
  6855. * Creates a new bounding box
  6856. * @param min defines the minimum vector (in local space)
  6857. * @param max defines the maximum vector (in local space)
  6858. * @param worldMatrix defines the new world matrix
  6859. */
  6860. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6861. /**
  6862. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6863. * @param min defines the new minimum vector (in local space)
  6864. * @param max defines the new maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6868. /**
  6869. * Scale the current bounding box by applying a scale factor
  6870. * @param factor defines the scale factor to apply
  6871. * @returns the current bounding box
  6872. */
  6873. scale(factor: number): BoundingBox;
  6874. /**
  6875. * Gets the world matrix of the bounding box
  6876. * @returns a matrix
  6877. */
  6878. getWorldMatrix(): DeepImmutable<Matrix>;
  6879. /** @hidden */
  6880. _update(world: DeepImmutable<Matrix>): void;
  6881. /**
  6882. * Tests if the bounding box is intersecting the frustum planes
  6883. * @param frustumPlanes defines the frustum planes to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6887. /**
  6888. * Tests if the bounding box is entirely inside the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an inclusion
  6891. */
  6892. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding box
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding box
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Tests if the bounding box intersects with a bounding sphere
  6901. * @param sphere defines the sphere to test
  6902. * @returns true if there is an intersection
  6903. */
  6904. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6905. /**
  6906. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6907. * @param min defines the min vector to use
  6908. * @param max defines the max vector to use
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6912. /**
  6913. * Tests if two bounding boxes are intersections
  6914. * @param box0 defines the first box to test
  6915. * @param box1 defines the second box to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6919. /**
  6920. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6921. * @param minPoint defines the minimum vector of the bounding box
  6922. * @param maxPoint defines the maximum vector of the bounding box
  6923. * @param sphereCenter defines the sphere center
  6924. * @param sphereRadius defines the sphere radius
  6925. * @returns true if there is an intersection
  6926. */
  6927. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6928. /**
  6929. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6930. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6931. * @param frustumPlanes defines the frustum planes to test
  6932. * @return true if there is an inclusion
  6933. */
  6934. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an intersection
  6940. */
  6941. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. }
  6943. }
  6944. declare module BABYLON {
  6945. /** @hidden */
  6946. export class Collider {
  6947. /** Define if a collision was found */
  6948. collisionFound: boolean;
  6949. /**
  6950. * Define last intersection point in local space
  6951. */
  6952. intersectionPoint: Vector3;
  6953. /**
  6954. * Define last collided mesh
  6955. */
  6956. collidedMesh: Nullable<AbstractMesh>;
  6957. private _collisionPoint;
  6958. private _planeIntersectionPoint;
  6959. private _tempVector;
  6960. private _tempVector2;
  6961. private _tempVector3;
  6962. private _tempVector4;
  6963. private _edge;
  6964. private _baseToVertex;
  6965. private _destinationPoint;
  6966. private _slidePlaneNormal;
  6967. private _displacementVector;
  6968. /** @hidden */
  6969. _radius: Vector3;
  6970. /** @hidden */
  6971. _retry: number;
  6972. private _velocity;
  6973. private _basePoint;
  6974. private _epsilon;
  6975. /** @hidden */
  6976. _velocityWorldLength: number;
  6977. /** @hidden */
  6978. _basePointWorld: Vector3;
  6979. private _velocityWorld;
  6980. private _normalizedVelocity;
  6981. /** @hidden */
  6982. _initialVelocity: Vector3;
  6983. /** @hidden */
  6984. _initialPosition: Vector3;
  6985. private _nearestDistance;
  6986. private _collisionMask;
  6987. get collisionMask(): number;
  6988. set collisionMask(mask: number);
  6989. /**
  6990. * Gets the plane normal used to compute the sliding response (in local space)
  6991. */
  6992. get slidePlaneNormal(): Vector3;
  6993. /** @hidden */
  6994. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6995. /** @hidden */
  6996. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6997. /** @hidden */
  6998. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6999. /** @hidden */
  7000. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7001. /** @hidden */
  7002. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _getResponse(pos: Vector3, vel: Vector3): void;
  7005. }
  7006. }
  7007. declare module BABYLON {
  7008. /**
  7009. * Interface for cullable objects
  7010. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7011. */
  7012. export interface ICullable {
  7013. /**
  7014. * Checks if the object or part of the object is in the frustum
  7015. * @param frustumPlanes Camera near/planes
  7016. * @returns true if the object is in frustum otherwise false
  7017. */
  7018. isInFrustum(frustumPlanes: Plane[]): boolean;
  7019. /**
  7020. * Checks if a cullable object (mesh...) is in the camera frustum
  7021. * Unlike isInFrustum this cheks the full bounding box
  7022. * @param frustumPlanes Camera near/planes
  7023. * @returns true if the object is in frustum otherwise false
  7024. */
  7025. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7026. }
  7027. /**
  7028. * Info for a bounding data of a mesh
  7029. */
  7030. export class BoundingInfo implements ICullable {
  7031. /**
  7032. * Bounding box for the mesh
  7033. */
  7034. readonly boundingBox: BoundingBox;
  7035. /**
  7036. * Bounding sphere for the mesh
  7037. */
  7038. readonly boundingSphere: BoundingSphere;
  7039. private _isLocked;
  7040. private static readonly TmpVector3;
  7041. /**
  7042. * Constructs bounding info
  7043. * @param minimum min vector of the bounding box/sphere
  7044. * @param maximum max vector of the bounding box/sphere
  7045. * @param worldMatrix defines the new world matrix
  7046. */
  7047. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7048. /**
  7049. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7050. * @param min defines the new minimum vector (in local space)
  7051. * @param max defines the new maximum vector (in local space)
  7052. * @param worldMatrix defines the new world matrix
  7053. */
  7054. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * min vector of the bounding box/sphere
  7057. */
  7058. get minimum(): Vector3;
  7059. /**
  7060. * max vector of the bounding box/sphere
  7061. */
  7062. get maximum(): Vector3;
  7063. /**
  7064. * If the info is locked and won't be updated to avoid perf overhead
  7065. */
  7066. get isLocked(): boolean;
  7067. set isLocked(value: boolean);
  7068. /**
  7069. * Updates the bounding sphere and box
  7070. * @param world world matrix to be used to update
  7071. */
  7072. update(world: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7075. * @param center New center of the bounding info
  7076. * @param extend New extend of the bounding info
  7077. * @returns the current bounding info
  7078. */
  7079. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7080. /**
  7081. * Scale the current bounding info by applying a scale factor
  7082. * @param factor defines the scale factor to apply
  7083. * @returns the current bounding info
  7084. */
  7085. scale(factor: number): BoundingInfo;
  7086. /**
  7087. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7088. * @param frustumPlanes defines the frustum to test
  7089. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7090. * @returns true if the bounding info is in the frustum planes
  7091. */
  7092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7093. /**
  7094. * Gets the world distance between the min and max points of the bounding box
  7095. */
  7096. get diagonalLength(): number;
  7097. /**
  7098. * Checks if a cullable object (mesh...) is in the camera frustum
  7099. * Unlike isInFrustum this cheks the full bounding box
  7100. * @param frustumPlanes Camera near/planes
  7101. * @returns true if the object is in frustum otherwise false
  7102. */
  7103. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. /** @hidden */
  7105. _checkCollision(collider: Collider): boolean;
  7106. /**
  7107. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7108. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7109. * @param point the point to check intersection with
  7110. * @returns if the point intersects
  7111. */
  7112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7113. /**
  7114. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param boundingInfo the bounding info to check intersection with
  7117. * @param precise if the intersection should be done using OBB
  7118. * @returns if the bounding info intersects
  7119. */
  7120. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. /**
  7125. * Extracts minimum and maximum values from a list of indexed positions
  7126. * @param positions defines the positions to use
  7127. * @param indices defines the indices to the positions
  7128. * @param indexStart defines the start index
  7129. * @param indexCount defines the end index
  7130. * @param bias defines bias value to add to the result
  7131. * @return minimum and maximum values
  7132. */
  7133. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7134. minimum: Vector3;
  7135. maximum: Vector3;
  7136. };
  7137. /**
  7138. * Extracts minimum and maximum values from a list of positions
  7139. * @param positions defines the positions to use
  7140. * @param start defines the start index in the positions array
  7141. * @param count defines the number of positions to handle
  7142. * @param bias defines bias value to add to the result
  7143. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7144. * @return minimum and maximum values
  7145. */
  7146. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7147. minimum: Vector3;
  7148. maximum: Vector3;
  7149. };
  7150. }
  7151. declare module BABYLON {
  7152. /** @hidden */
  7153. export class WebGLDataBuffer extends DataBuffer {
  7154. private _buffer;
  7155. constructor(resource: WebGLBuffer);
  7156. get underlyingResource(): any;
  7157. }
  7158. }
  7159. declare module BABYLON {
  7160. /** @hidden */
  7161. export class WebGLPipelineContext implements IPipelineContext {
  7162. engine: ThinEngine;
  7163. program: Nullable<WebGLProgram>;
  7164. context?: WebGLRenderingContext;
  7165. vertexShader?: WebGLShader;
  7166. fragmentShader?: WebGLShader;
  7167. isParallelCompiled: boolean;
  7168. onCompiled?: () => void;
  7169. transformFeedback?: WebGLTransformFeedback | null;
  7170. vertexCompilationError: Nullable<string>;
  7171. fragmentCompilationError: Nullable<string>;
  7172. programLinkError: Nullable<string>;
  7173. programValidationError: Nullable<string>;
  7174. get isAsync(): boolean;
  7175. get isReady(): boolean;
  7176. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7177. _getVertexShaderCode(): string | null;
  7178. _getFragmentShaderCode(): string | null;
  7179. }
  7180. }
  7181. declare module BABYLON {
  7182. interface ThinEngine {
  7183. /**
  7184. * Create an uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Create a dynamic uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param elements defines the content of the uniform buffer
  7194. * @returns the webGL uniform buffer
  7195. */
  7196. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7197. /**
  7198. * Update an existing uniform buffer
  7199. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7200. * @param uniformBuffer defines the target uniform buffer
  7201. * @param elements defines the content to update
  7202. * @param offset defines the offset in the uniform buffer where update should start
  7203. * @param count defines the size of the data to update
  7204. */
  7205. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7206. /**
  7207. * Bind an uniform buffer to the current webGL context
  7208. * @param buffer defines the buffer to bind
  7209. */
  7210. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7211. /**
  7212. * Bind a buffer to the current webGL context at a given location
  7213. * @param buffer defines the buffer to bind
  7214. * @param location defines the index where to bind the buffer
  7215. */
  7216. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7217. /**
  7218. * Bind a specific block at a given index in a specific shader program
  7219. * @param pipelineContext defines the pipeline context to use
  7220. * @param blockName defines the block name
  7221. * @param index defines the index where to bind the block
  7222. */
  7223. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. get useUbo(): boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. get isSync(): boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module BABYLON {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module BABYLON {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. interface ThinEngine {
  7602. /**
  7603. * Creates a depth stencil cube texture.
  7604. * This is only available in WebGL 2.
  7605. * @param size The size of face edge in the cube texture.
  7606. * @param options The options defining the cube texture.
  7607. * @returns The cube texture
  7608. */
  7609. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7610. /**
  7611. * Creates a cube texture
  7612. * @param rootUrl defines the url where the files to load is located
  7613. * @param scene defines the current scene
  7614. * @param files defines the list of files to load (1 per face)
  7615. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7616. * @param onLoad defines an optional callback raised when the texture is loaded
  7617. * @param onError defines an optional callback raised if there is an issue to load the texture
  7618. * @param format defines the format of the data
  7619. * @param forcedExtension defines the extension to use to pick the right loader
  7620. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7621. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7622. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7623. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7624. * @returns the cube texture as an InternalTexture
  7625. */
  7626. 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>): InternalTexture;
  7627. /**
  7628. * Creates a cube texture
  7629. * @param rootUrl defines the url where the files to load is located
  7630. * @param scene defines the current scene
  7631. * @param files defines the list of files to load (1 per face)
  7632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7633. * @param onLoad defines an optional callback raised when the texture is loaded
  7634. * @param onError defines an optional callback raised if there is an issue to load the texture
  7635. * @param format defines the format of the data
  7636. * @param forcedExtension defines the extension to use to pick the right loader
  7637. * @returns the cube texture as an InternalTexture
  7638. */
  7639. 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;
  7640. /**
  7641. * Creates a cube texture
  7642. * @param rootUrl defines the url where the files to load is located
  7643. * @param scene defines the current scene
  7644. * @param files defines the list of files to load (1 per face)
  7645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7646. * @param onLoad defines an optional callback raised when the texture is loaded
  7647. * @param onError defines an optional callback raised if there is an issue to load the texture
  7648. * @param format defines the format of the data
  7649. * @param forcedExtension defines the extension to use to pick the right loader
  7650. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7653. * @returns the cube texture as an InternalTexture
  7654. */
  7655. 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;
  7656. /** @hidden */
  7657. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7660. /** @hidden */
  7661. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /** @hidden */
  7663. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7664. /**
  7665. * @hidden
  7666. */
  7667. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class for creating a cube texture
  7673. */
  7674. export class CubeTexture extends BaseTexture {
  7675. private _delayedOnLoad;
  7676. /**
  7677. * Observable triggered once the texture has been loaded.
  7678. */
  7679. onLoadObservable: Observable<CubeTexture>;
  7680. /**
  7681. * The url of the texture
  7682. */
  7683. url: string;
  7684. /**
  7685. * Gets or sets the center of the bounding box associated with the cube texture.
  7686. * It must define where the camera used to render the texture was set
  7687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7688. */
  7689. boundingBoxPosition: Vector3;
  7690. private _boundingBoxSize;
  7691. /**
  7692. * Gets or sets the size of the bounding box associated with the cube texture
  7693. * When defined, the cubemap will switch to local mode
  7694. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7695. * @example https://www.babylonjs-playground.com/#RNASML
  7696. */
  7697. set boundingBoxSize(value: Vector3);
  7698. /**
  7699. * Returns the bounding box size
  7700. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7701. */
  7702. get boundingBoxSize(): Vector3;
  7703. protected _rotationY: number;
  7704. /**
  7705. * Sets texture matrix rotation angle around Y axis in radians.
  7706. */
  7707. set rotationY(value: number);
  7708. /**
  7709. * Gets texture matrix rotation angle around Y axis radians.
  7710. */
  7711. get rotationY(): number;
  7712. /**
  7713. * Are mip maps generated for this texture or not.
  7714. */
  7715. get noMipmap(): boolean;
  7716. private _noMipmap;
  7717. private _files;
  7718. protected _forcedExtension: Nullable<string>;
  7719. private _extensions;
  7720. private _textureMatrix;
  7721. private _format;
  7722. private _createPolynomials;
  7723. /** @hidden */
  7724. _prefiltered: boolean;
  7725. /**
  7726. * Creates a cube texture from an array of image urls
  7727. * @param files defines an array of image urls
  7728. * @param scene defines the hosting scene
  7729. * @param noMipmap specifies if mip maps are not used
  7730. * @returns a cube texture
  7731. */
  7732. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7733. /**
  7734. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7735. * @param url defines the url of the prefiltered texture
  7736. * @param scene defines the scene the texture is attached to
  7737. * @param forcedExtension defines the extension of the file if different from the url
  7738. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7739. * @return the prefiltered texture
  7740. */
  7741. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7742. /**
  7743. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7744. * as prefiltered data.
  7745. * @param rootUrl defines the url of the texture or the root name of the six images
  7746. * @param scene defines the scene the texture is attached to
  7747. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7748. * @param noMipmap defines if mipmaps should be created or not
  7749. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7750. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7751. * @param onError defines a callback triggered in case of error during load
  7752. * @param format defines the internal format to use for the texture once loaded
  7753. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7754. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7755. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7756. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7757. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7758. * @return the cube texture
  7759. */
  7760. 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);
  7761. /**
  7762. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7763. */
  7764. get isPrefiltered(): boolean;
  7765. /**
  7766. * Get the current class name of the texture useful for serialization or dynamic coding.
  7767. * @returns "CubeTexture"
  7768. */
  7769. getClassName(): string;
  7770. /**
  7771. * Update the url (and optional buffer) of this texture if url was null during construction.
  7772. * @param url the url of the texture
  7773. * @param forcedExtension defines the extension to use
  7774. * @param onLoad callback called when the texture is loaded (defaults to null)
  7775. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7776. */
  7777. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7778. /**
  7779. * Delays loading of the cube texture
  7780. * @param forcedExtension defines the extension to use
  7781. */
  7782. delayLoad(forcedExtension?: string): void;
  7783. /**
  7784. * Returns the reflection texture matrix
  7785. * @returns the reflection texture matrix
  7786. */
  7787. getReflectionTextureMatrix(): Matrix;
  7788. /**
  7789. * Sets the reflection texture matrix
  7790. * @param value Reflection texture matrix
  7791. */
  7792. setReflectionTextureMatrix(value: Matrix): void;
  7793. /**
  7794. * Parses text to create a cube texture
  7795. * @param parsedTexture define the serialized text to read from
  7796. * @param scene defines the hosting scene
  7797. * @param rootUrl defines the root url of the cube texture
  7798. * @returns a cube texture
  7799. */
  7800. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7801. /**
  7802. * Makes a clone, or deep copy, of the cube texture
  7803. * @returns a new cube texture
  7804. */
  7805. clone(): CubeTexture;
  7806. }
  7807. }
  7808. declare module BABYLON {
  7809. /**
  7810. * Manages the defines for the Material
  7811. */
  7812. export class MaterialDefines {
  7813. /** @hidden */
  7814. protected _keys: string[];
  7815. private _isDirty;
  7816. /** @hidden */
  7817. _renderId: number;
  7818. /** @hidden */
  7819. _areLightsDirty: boolean;
  7820. /** @hidden */
  7821. _areLightsDisposed: boolean;
  7822. /** @hidden */
  7823. _areAttributesDirty: boolean;
  7824. /** @hidden */
  7825. _areTexturesDirty: boolean;
  7826. /** @hidden */
  7827. _areFresnelDirty: boolean;
  7828. /** @hidden */
  7829. _areMiscDirty: boolean;
  7830. /** @hidden */
  7831. _areImageProcessingDirty: boolean;
  7832. /** @hidden */
  7833. _normals: boolean;
  7834. /** @hidden */
  7835. _uvs: boolean;
  7836. /** @hidden */
  7837. _needNormals: boolean;
  7838. /** @hidden */
  7839. _needUVs: boolean;
  7840. [id: string]: any;
  7841. /**
  7842. * Specifies if the material needs to be re-calculated
  7843. */
  7844. get isDirty(): boolean;
  7845. /**
  7846. * Marks the material to indicate that it has been re-calculated
  7847. */
  7848. markAsProcessed(): void;
  7849. /**
  7850. * Marks the material to indicate that it needs to be re-calculated
  7851. */
  7852. markAsUnprocessed(): void;
  7853. /**
  7854. * Marks the material to indicate all of its defines need to be re-calculated
  7855. */
  7856. markAllAsDirty(): void;
  7857. /**
  7858. * Marks the material to indicate that image processing needs to be re-calculated
  7859. */
  7860. markAsImageProcessingDirty(): void;
  7861. /**
  7862. * Marks the material to indicate the lights need to be re-calculated
  7863. * @param disposed Defines whether the light is dirty due to dispose or not
  7864. */
  7865. markAsLightDirty(disposed?: boolean): void;
  7866. /**
  7867. * Marks the attribute state as changed
  7868. */
  7869. markAsAttributesDirty(): void;
  7870. /**
  7871. * Marks the texture state as changed
  7872. */
  7873. markAsTexturesDirty(): void;
  7874. /**
  7875. * Marks the fresnel state as changed
  7876. */
  7877. markAsFresnelDirty(): void;
  7878. /**
  7879. * Marks the misc state as changed
  7880. */
  7881. markAsMiscDirty(): void;
  7882. /**
  7883. * Rebuilds the material defines
  7884. */
  7885. rebuild(): void;
  7886. /**
  7887. * Specifies if two material defines are equal
  7888. * @param other - A material define instance to compare to
  7889. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7890. */
  7891. isEqual(other: MaterialDefines): boolean;
  7892. /**
  7893. * Clones this instance's defines to another instance
  7894. * @param other - material defines to clone values to
  7895. */
  7896. cloneTo(other: MaterialDefines): void;
  7897. /**
  7898. * Resets the material define values
  7899. */
  7900. reset(): void;
  7901. /**
  7902. * Converts the material define values to a string
  7903. * @returns - String of material define information
  7904. */
  7905. toString(): string;
  7906. }
  7907. }
  7908. declare module BABYLON {
  7909. /**
  7910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7912. * 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;
  7913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7914. */
  7915. export class ColorCurves {
  7916. private _dirty;
  7917. private _tempColor;
  7918. private _globalCurve;
  7919. private _highlightsCurve;
  7920. private _midtonesCurve;
  7921. private _shadowsCurve;
  7922. private _positiveCurve;
  7923. private _negativeCurve;
  7924. private _globalHue;
  7925. private _globalDensity;
  7926. private _globalSaturation;
  7927. private _globalExposure;
  7928. /**
  7929. * Gets the global Hue value.
  7930. * 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).
  7931. */
  7932. get globalHue(): number;
  7933. /**
  7934. * Sets the global Hue value.
  7935. * 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).
  7936. */
  7937. set globalHue(value: number);
  7938. /**
  7939. * Gets the global Density value.
  7940. * 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.
  7941. * Values less than zero provide a filter of opposite hue.
  7942. */
  7943. get globalDensity(): number;
  7944. /**
  7945. * Sets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. set globalDensity(value: number);
  7950. /**
  7951. * Gets the global Saturation value.
  7952. * 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.
  7953. */
  7954. get globalSaturation(): number;
  7955. /**
  7956. * Sets the global Saturation value.
  7957. * 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.
  7958. */
  7959. set globalSaturation(value: number);
  7960. /**
  7961. * Gets the global Exposure value.
  7962. * 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.
  7963. */
  7964. get globalExposure(): number;
  7965. /**
  7966. * Sets the global Exposure value.
  7967. * 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.
  7968. */
  7969. set globalExposure(value: number);
  7970. private _highlightsHue;
  7971. private _highlightsDensity;
  7972. private _highlightsSaturation;
  7973. private _highlightsExposure;
  7974. /**
  7975. * Gets the highlights Hue value.
  7976. * 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).
  7977. */
  7978. get highlightsHue(): number;
  7979. /**
  7980. * Sets the highlights Hue value.
  7981. * 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).
  7982. */
  7983. set highlightsHue(value: number);
  7984. /**
  7985. * Gets the highlights Density value.
  7986. * 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.
  7987. * Values less than zero provide a filter of opposite hue.
  7988. */
  7989. get highlightsDensity(): number;
  7990. /**
  7991. * Sets the highlights Density value.
  7992. * 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.
  7993. * Values less than zero provide a filter of opposite hue.
  7994. */
  7995. set highlightsDensity(value: number);
  7996. /**
  7997. * Gets the highlights Saturation value.
  7998. * 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.
  7999. */
  8000. get highlightsSaturation(): number;
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * 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.
  8004. */
  8005. set highlightsSaturation(value: number);
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. get highlightsExposure(): number;
  8011. /**
  8012. * Sets the highlights Exposure value.
  8013. * 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.
  8014. */
  8015. set highlightsExposure(value: number);
  8016. private _midtonesHue;
  8017. private _midtonesDensity;
  8018. private _midtonesSaturation;
  8019. private _midtonesExposure;
  8020. /**
  8021. * Gets the midtones Hue value.
  8022. * 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).
  8023. */
  8024. get midtonesHue(): number;
  8025. /**
  8026. * Sets the midtones Hue value.
  8027. * 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).
  8028. */
  8029. set midtonesHue(value: number);
  8030. /**
  8031. * Gets the midtones Density value.
  8032. * 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.
  8033. * Values less than zero provide a filter of opposite hue.
  8034. */
  8035. get midtonesDensity(): number;
  8036. /**
  8037. * Sets the midtones Density value.
  8038. * 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.
  8039. * Values less than zero provide a filter of opposite hue.
  8040. */
  8041. set midtonesDensity(value: number);
  8042. /**
  8043. * Gets the midtones Saturation value.
  8044. * 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.
  8045. */
  8046. get midtonesSaturation(): number;
  8047. /**
  8048. * Sets the midtones Saturation value.
  8049. * 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.
  8050. */
  8051. set midtonesSaturation(value: number);
  8052. /**
  8053. * Gets the midtones Exposure value.
  8054. * 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.
  8055. */
  8056. get midtonesExposure(): number;
  8057. /**
  8058. * Sets the midtones Exposure value.
  8059. * 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.
  8060. */
  8061. set midtonesExposure(value: number);
  8062. private _shadowsHue;
  8063. private _shadowsDensity;
  8064. private _shadowsSaturation;
  8065. private _shadowsExposure;
  8066. /**
  8067. * Gets the shadows Hue value.
  8068. * 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).
  8069. */
  8070. get shadowsHue(): number;
  8071. /**
  8072. * Sets the shadows Hue value.
  8073. * 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).
  8074. */
  8075. set shadowsHue(value: number);
  8076. /**
  8077. * Gets the shadows Density value.
  8078. * 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.
  8079. * Values less than zero provide a filter of opposite hue.
  8080. */
  8081. get shadowsDensity(): number;
  8082. /**
  8083. * Sets the shadows Density value.
  8084. * 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.
  8085. * Values less than zero provide a filter of opposite hue.
  8086. */
  8087. set shadowsDensity(value: number);
  8088. /**
  8089. * Gets the shadows Saturation value.
  8090. * 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.
  8091. */
  8092. get shadowsSaturation(): number;
  8093. /**
  8094. * Sets the shadows Saturation value.
  8095. * 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.
  8096. */
  8097. set shadowsSaturation(value: number);
  8098. /**
  8099. * Gets the shadows Exposure value.
  8100. * 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.
  8101. */
  8102. get shadowsExposure(): number;
  8103. /**
  8104. * Sets the shadows Exposure value.
  8105. * 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.
  8106. */
  8107. set shadowsExposure(value: number);
  8108. /**
  8109. * Returns the class name
  8110. * @returns The class name
  8111. */
  8112. getClassName(): string;
  8113. /**
  8114. * Binds the color curves to the shader.
  8115. * @param colorCurves The color curve to bind
  8116. * @param effect The effect to bind to
  8117. * @param positiveUniform The positive uniform shader parameter
  8118. * @param neutralUniform The neutral uniform shader parameter
  8119. * @param negativeUniform The negative uniform shader parameter
  8120. */
  8121. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8122. /**
  8123. * Prepare the list of uniforms associated with the ColorCurves effects.
  8124. * @param uniformsList The list of uniforms used in the effect
  8125. */
  8126. static PrepareUniforms(uniformsList: string[]): void;
  8127. /**
  8128. * Returns color grading data based on a hue, density, saturation and exposure value.
  8129. * @param filterHue The hue of the color filter.
  8130. * @param filterDensity The density of the color filter.
  8131. * @param saturation The saturation.
  8132. * @param exposure The exposure.
  8133. * @param result The result data container.
  8134. */
  8135. private getColorGradingDataToRef;
  8136. /**
  8137. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8138. * @param value The input slider value in range [-100,100].
  8139. * @returns Adjusted value.
  8140. */
  8141. private static applyColorGradingSliderNonlinear;
  8142. /**
  8143. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8144. * @param hue The hue (H) input.
  8145. * @param saturation The saturation (S) input.
  8146. * @param brightness The brightness (B) input.
  8147. * @result An RGBA color represented as Vector4.
  8148. */
  8149. private static fromHSBToRef;
  8150. /**
  8151. * Returns a value clamped between min and max
  8152. * @param value The value to clamp
  8153. * @param min The minimum of value
  8154. * @param max The maximum of value
  8155. * @returns The clamped value.
  8156. */
  8157. private static clamp;
  8158. /**
  8159. * Clones the current color curve instance.
  8160. * @return The cloned curves
  8161. */
  8162. clone(): ColorCurves;
  8163. /**
  8164. * Serializes the current color curve instance to a json representation.
  8165. * @return a JSON representation
  8166. */
  8167. serialize(): any;
  8168. /**
  8169. * Parses the color curve from a json representation.
  8170. * @param source the JSON source to parse
  8171. * @return The parsed curves
  8172. */
  8173. static Parse(source: any): ColorCurves;
  8174. }
  8175. }
  8176. declare module BABYLON {
  8177. /**
  8178. * Interface to follow in your material defines to integrate easily the
  8179. * Image proccessing functions.
  8180. * @hidden
  8181. */
  8182. export interface IImageProcessingConfigurationDefines {
  8183. IMAGEPROCESSING: boolean;
  8184. VIGNETTE: boolean;
  8185. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8186. VIGNETTEBLENDMODEOPAQUE: boolean;
  8187. TONEMAPPING: boolean;
  8188. TONEMAPPING_ACES: boolean;
  8189. CONTRAST: boolean;
  8190. EXPOSURE: boolean;
  8191. COLORCURVES: boolean;
  8192. COLORGRADING: boolean;
  8193. COLORGRADING3D: boolean;
  8194. SAMPLER3DGREENDEPTH: boolean;
  8195. SAMPLER3DBGRMAP: boolean;
  8196. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8197. }
  8198. /**
  8199. * @hidden
  8200. */
  8201. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8202. IMAGEPROCESSING: boolean;
  8203. VIGNETTE: boolean;
  8204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8205. VIGNETTEBLENDMODEOPAQUE: boolean;
  8206. TONEMAPPING: boolean;
  8207. TONEMAPPING_ACES: boolean;
  8208. CONTRAST: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. EXPOSURE: boolean;
  8216. constructor();
  8217. }
  8218. /**
  8219. * This groups together the common properties used for image processing either in direct forward pass
  8220. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8221. * or not.
  8222. */
  8223. export class ImageProcessingConfiguration {
  8224. /**
  8225. * Default tone mapping applied in BabylonJS.
  8226. */
  8227. static readonly TONEMAPPING_STANDARD: number;
  8228. /**
  8229. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8230. * to other engines rendering to increase portability.
  8231. */
  8232. static readonly TONEMAPPING_ACES: number;
  8233. /**
  8234. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8235. */
  8236. colorCurves: Nullable<ColorCurves>;
  8237. private _colorCurvesEnabled;
  8238. /**
  8239. * Gets wether the color curves effect is enabled.
  8240. */
  8241. get colorCurvesEnabled(): boolean;
  8242. /**
  8243. * Sets wether the color curves effect is enabled.
  8244. */
  8245. set colorCurvesEnabled(value: boolean);
  8246. private _colorGradingTexture;
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. get colorGradingTexture(): Nullable<BaseTexture>;
  8251. /**
  8252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8253. */
  8254. set colorGradingTexture(value: Nullable<BaseTexture>);
  8255. private _colorGradingEnabled;
  8256. /**
  8257. * Gets wether the color grading effect is enabled.
  8258. */
  8259. get colorGradingEnabled(): boolean;
  8260. /**
  8261. * Sets wether the color grading effect is enabled.
  8262. */
  8263. set colorGradingEnabled(value: boolean);
  8264. private _colorGradingWithGreenDepth;
  8265. /**
  8266. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8267. */
  8268. get colorGradingWithGreenDepth(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8271. */
  8272. set colorGradingWithGreenDepth(value: boolean);
  8273. private _colorGradingBGR;
  8274. /**
  8275. * Gets wether the color grading texture contains BGR values.
  8276. */
  8277. get colorGradingBGR(): boolean;
  8278. /**
  8279. * Sets wether the color grading texture contains BGR values.
  8280. */
  8281. set colorGradingBGR(value: boolean);
  8282. /** @hidden */
  8283. _exposure: number;
  8284. /**
  8285. * Gets the Exposure used in the effect.
  8286. */
  8287. get exposure(): number;
  8288. /**
  8289. * Sets the Exposure used in the effect.
  8290. */
  8291. set exposure(value: number);
  8292. private _toneMappingEnabled;
  8293. /**
  8294. * Gets wether the tone mapping effect is enabled.
  8295. */
  8296. get toneMappingEnabled(): boolean;
  8297. /**
  8298. * Sets wether the tone mapping effect is enabled.
  8299. */
  8300. set toneMappingEnabled(value: boolean);
  8301. private _toneMappingType;
  8302. /**
  8303. * Gets the type of tone mapping effect.
  8304. */
  8305. get toneMappingType(): number;
  8306. /**
  8307. * Sets the type of tone mapping effect used in BabylonJS.
  8308. */
  8309. set toneMappingType(value: number);
  8310. protected _contrast: number;
  8311. /**
  8312. * Gets the contrast used in the effect.
  8313. */
  8314. get contrast(): number;
  8315. /**
  8316. * Sets the contrast used in the effect.
  8317. */
  8318. set contrast(value: number);
  8319. /**
  8320. * Vignette stretch size.
  8321. */
  8322. vignetteStretch: number;
  8323. /**
  8324. * Vignette centre X Offset.
  8325. */
  8326. vignetteCentreX: number;
  8327. /**
  8328. * Vignette centre Y Offset.
  8329. */
  8330. vignetteCentreY: number;
  8331. /**
  8332. * Vignette weight or intensity of the vignette effect.
  8333. */
  8334. vignetteWeight: number;
  8335. /**
  8336. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8337. * if vignetteEnabled is set to true.
  8338. */
  8339. vignetteColor: Color4;
  8340. /**
  8341. * Camera field of view used by the Vignette effect.
  8342. */
  8343. vignetteCameraFov: number;
  8344. private _vignetteBlendMode;
  8345. /**
  8346. * Gets the vignette blend mode allowing different kind of effect.
  8347. */
  8348. get vignetteBlendMode(): number;
  8349. /**
  8350. * Sets the vignette blend mode allowing different kind of effect.
  8351. */
  8352. set vignetteBlendMode(value: number);
  8353. private _vignetteEnabled;
  8354. /**
  8355. * Gets wether the vignette effect is enabled.
  8356. */
  8357. get vignetteEnabled(): boolean;
  8358. /**
  8359. * Sets wether the vignette effect is enabled.
  8360. */
  8361. set vignetteEnabled(value: boolean);
  8362. private _applyByPostProcess;
  8363. /**
  8364. * Gets wether the image processing is applied through a post process or not.
  8365. */
  8366. get applyByPostProcess(): boolean;
  8367. /**
  8368. * Sets wether the image processing is applied through a post process or not.
  8369. */
  8370. set applyByPostProcess(value: boolean);
  8371. private _isEnabled;
  8372. /**
  8373. * Gets wether the image processing is enabled or not.
  8374. */
  8375. get isEnabled(): boolean;
  8376. /**
  8377. * Sets wether the image processing is enabled or not.
  8378. */
  8379. set isEnabled(value: boolean);
  8380. /**
  8381. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8382. */
  8383. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8384. /**
  8385. * Method called each time the image processing information changes requires to recompile the effect.
  8386. */
  8387. protected _updateParameters(): void;
  8388. /**
  8389. * Gets the current class name.
  8390. * @return "ImageProcessingConfiguration"
  8391. */
  8392. getClassName(): string;
  8393. /**
  8394. * Prepare the list of uniforms associated with the Image Processing effects.
  8395. * @param uniforms The list of uniforms used in the effect
  8396. * @param defines the list of defines currently in use
  8397. */
  8398. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8399. /**
  8400. * Prepare the list of samplers associated with the Image Processing effects.
  8401. * @param samplersList The list of uniforms used in the effect
  8402. * @param defines the list of defines currently in use
  8403. */
  8404. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8405. /**
  8406. * Prepare the list of defines associated to the shader.
  8407. * @param defines the list of defines to complete
  8408. * @param forPostProcess Define if we are currently in post process mode or not
  8409. */
  8410. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8411. /**
  8412. * Returns true if all the image processing information are ready.
  8413. * @returns True if ready, otherwise, false
  8414. */
  8415. isReady(): boolean;
  8416. /**
  8417. * Binds the image processing to the shader.
  8418. * @param effect The effect to bind to
  8419. * @param overrideAspectRatio Override the aspect ratio of the effect
  8420. */
  8421. bind(effect: Effect, overrideAspectRatio?: number): void;
  8422. /**
  8423. * Clones the current image processing instance.
  8424. * @return The cloned image processing
  8425. */
  8426. clone(): ImageProcessingConfiguration;
  8427. /**
  8428. * Serializes the current image processing instance to a json representation.
  8429. * @return a JSON representation
  8430. */
  8431. serialize(): any;
  8432. /**
  8433. * Parses the image processing from a json representation.
  8434. * @param source the JSON source to parse
  8435. * @return The parsed image processing
  8436. */
  8437. static Parse(source: any): ImageProcessingConfiguration;
  8438. private static _VIGNETTEMODE_MULTIPLY;
  8439. private static _VIGNETTEMODE_OPAQUE;
  8440. /**
  8441. * Used to apply the vignette as a mix with the pixel color.
  8442. */
  8443. static get VIGNETTEMODE_MULTIPLY(): number;
  8444. /**
  8445. * Used to apply the vignette as a replacement of the pixel color.
  8446. */
  8447. static get VIGNETTEMODE_OPAQUE(): number;
  8448. }
  8449. }
  8450. declare module BABYLON {
  8451. /** @hidden */
  8452. export var postprocessVertexShader: {
  8453. name: string;
  8454. shader: string;
  8455. };
  8456. }
  8457. declare module BABYLON {
  8458. interface ThinEngine {
  8459. /**
  8460. * Creates a new render target texture
  8461. * @param size defines the size of the texture
  8462. * @param options defines the options used to create the texture
  8463. * @returns a new render target texture stored in an InternalTexture
  8464. */
  8465. createRenderTargetTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. layers?: number;
  8469. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8470. /**
  8471. * Creates a depth stencil texture.
  8472. * This is only available in WebGL 2 or with the depth texture extension available.
  8473. * @param size The size of face edge in the texture.
  8474. * @param options The options defining the texture.
  8475. * @returns The texture
  8476. */
  8477. createDepthStencilTexture(size: number | {
  8478. width: number;
  8479. height: number;
  8480. layers?: number;
  8481. }, options: DepthTextureCreationOptions): InternalTexture;
  8482. /** @hidden */
  8483. _createDepthStencilTexture(size: number | {
  8484. width: number;
  8485. height: number;
  8486. layers?: number;
  8487. }, options: DepthTextureCreationOptions): InternalTexture;
  8488. }
  8489. }
  8490. declare module BABYLON {
  8491. /** Defines supported spaces */
  8492. export enum Space {
  8493. /** Local (object) space */
  8494. LOCAL = 0,
  8495. /** World space */
  8496. WORLD = 1,
  8497. /** Bone space */
  8498. BONE = 2
  8499. }
  8500. /** Defines the 3 main axes */
  8501. export class Axis {
  8502. /** X axis */
  8503. static X: Vector3;
  8504. /** Y axis */
  8505. static Y: Vector3;
  8506. /** Z axis */
  8507. static Z: Vector3;
  8508. }
  8509. }
  8510. declare module BABYLON {
  8511. /**
  8512. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8513. * This is the base of the follow, arc rotate cameras and Free camera
  8514. * @see http://doc.babylonjs.com/features/cameras
  8515. */
  8516. export class TargetCamera extends Camera {
  8517. private static _RigCamTransformMatrix;
  8518. private static _TargetTransformMatrix;
  8519. private static _TargetFocalPoint;
  8520. /**
  8521. * Define the current direction the camera is moving to
  8522. */
  8523. cameraDirection: Vector3;
  8524. /**
  8525. * Define the current rotation the camera is rotating to
  8526. */
  8527. cameraRotation: Vector2;
  8528. /**
  8529. * When set, the up vector of the camera will be updated by the rotation of the camera
  8530. */
  8531. updateUpVectorFromRotation: boolean;
  8532. private _tmpQuaternion;
  8533. /**
  8534. * Define the current rotation of the camera
  8535. */
  8536. rotation: Vector3;
  8537. /**
  8538. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8539. */
  8540. rotationQuaternion: Quaternion;
  8541. /**
  8542. * Define the current speed of the camera
  8543. */
  8544. speed: number;
  8545. /**
  8546. * Add constraint to the camera to prevent it to move freely in all directions and
  8547. * around all axis.
  8548. */
  8549. noRotationConstraint: boolean;
  8550. /**
  8551. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8552. * panning
  8553. */
  8554. invertRotation: boolean;
  8555. /**
  8556. * Speed multiplier for inverse camera panning
  8557. */
  8558. inverseRotationSpeed: number;
  8559. /**
  8560. * Define the current target of the camera as an object or a position.
  8561. */
  8562. lockedTarget: any;
  8563. /** @hidden */
  8564. _currentTarget: Vector3;
  8565. /** @hidden */
  8566. _initialFocalDistance: number;
  8567. /** @hidden */
  8568. _viewMatrix: Matrix;
  8569. /** @hidden */
  8570. _camMatrix: Matrix;
  8571. /** @hidden */
  8572. _cameraTransformMatrix: Matrix;
  8573. /** @hidden */
  8574. _cameraRotationMatrix: Matrix;
  8575. /** @hidden */
  8576. _referencePoint: Vector3;
  8577. /** @hidden */
  8578. _transformedReferencePoint: Vector3;
  8579. protected _globalCurrentTarget: Vector3;
  8580. protected _globalCurrentUpVector: Vector3;
  8581. /** @hidden */
  8582. _reset: () => void;
  8583. private _defaultUp;
  8584. /**
  8585. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8586. * This is the base of the follow, arc rotate cameras and Free camera
  8587. * @see http://doc.babylonjs.com/features/cameras
  8588. * @param name Defines the name of the camera in the scene
  8589. * @param position Defines the start position of the camera in the scene
  8590. * @param scene Defines the scene the camera belongs to
  8591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8592. */
  8593. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8594. /**
  8595. * Gets the position in front of the camera at a given distance.
  8596. * @param distance The distance from the camera we want the position to be
  8597. * @returns the position
  8598. */
  8599. getFrontPosition(distance: number): Vector3;
  8600. /** @hidden */
  8601. _getLockedTargetPosition(): Nullable<Vector3>;
  8602. private _storedPosition;
  8603. private _storedRotation;
  8604. private _storedRotationQuaternion;
  8605. /**
  8606. * Store current camera state of the camera (fov, position, rotation, etc..)
  8607. * @returns the camera
  8608. */
  8609. storeState(): Camera;
  8610. /**
  8611. * Restored camera state. You must call storeState() first
  8612. * @returns whether it was successful or not
  8613. * @hidden
  8614. */
  8615. _restoreStateValues(): boolean;
  8616. /** @hidden */
  8617. _initCache(): void;
  8618. /** @hidden */
  8619. _updateCache(ignoreParentClass?: boolean): void;
  8620. /** @hidden */
  8621. _isSynchronizedViewMatrix(): boolean;
  8622. /** @hidden */
  8623. _computeLocalCameraSpeed(): number;
  8624. /**
  8625. * Defines the target the camera should look at.
  8626. * @param target Defines the new target as a Vector or a mesh
  8627. */
  8628. setTarget(target: Vector3): void;
  8629. /**
  8630. * Return the current target position of the camera. This value is expressed in local space.
  8631. * @returns the target position
  8632. */
  8633. getTarget(): Vector3;
  8634. /** @hidden */
  8635. _decideIfNeedsToMove(): boolean;
  8636. /** @hidden */
  8637. _updatePosition(): void;
  8638. /** @hidden */
  8639. _checkInputs(): void;
  8640. protected _updateCameraRotationMatrix(): void;
  8641. /**
  8642. * 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)
  8643. * @returns the current camera
  8644. */
  8645. private _rotateUpVectorWithCameraRotationMatrix;
  8646. private _cachedRotationZ;
  8647. private _cachedQuaternionRotationZ;
  8648. /** @hidden */
  8649. _getViewMatrix(): Matrix;
  8650. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8651. /**
  8652. * @hidden
  8653. */
  8654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8655. /**
  8656. * @hidden
  8657. */
  8658. _updateRigCameras(): void;
  8659. private _getRigCamPositionAndTarget;
  8660. /**
  8661. * Gets the current object class name.
  8662. * @return the class name
  8663. */
  8664. getClassName(): string;
  8665. }
  8666. }
  8667. declare module BABYLON {
  8668. /**
  8669. * Gather the list of keyboard event types as constants.
  8670. */
  8671. export class KeyboardEventTypes {
  8672. /**
  8673. * The keydown event is fired when a key becomes active (pressed).
  8674. */
  8675. static readonly KEYDOWN: number;
  8676. /**
  8677. * The keyup event is fired when a key has been released.
  8678. */
  8679. static readonly KEYUP: number;
  8680. }
  8681. /**
  8682. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8683. */
  8684. export class KeyboardInfo {
  8685. /**
  8686. * Defines the type of event (KeyboardEventTypes)
  8687. */
  8688. type: number;
  8689. /**
  8690. * Defines the related dom event
  8691. */
  8692. event: KeyboardEvent;
  8693. /**
  8694. * Instantiates a new keyboard info.
  8695. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8696. * @param type Defines the type of event (KeyboardEventTypes)
  8697. * @param event Defines the related dom event
  8698. */
  8699. constructor(
  8700. /**
  8701. * Defines the type of event (KeyboardEventTypes)
  8702. */
  8703. type: number,
  8704. /**
  8705. * Defines the related dom event
  8706. */
  8707. event: KeyboardEvent);
  8708. }
  8709. /**
  8710. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8711. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8712. */
  8713. export class KeyboardInfoPre extends KeyboardInfo {
  8714. /**
  8715. * Defines the type of event (KeyboardEventTypes)
  8716. */
  8717. type: number;
  8718. /**
  8719. * Defines the related dom event
  8720. */
  8721. event: KeyboardEvent;
  8722. /**
  8723. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8724. */
  8725. skipOnPointerObservable: boolean;
  8726. /**
  8727. * Instantiates a new keyboard pre info.
  8728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8729. * @param type Defines the type of event (KeyboardEventTypes)
  8730. * @param event Defines the related dom event
  8731. */
  8732. constructor(
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number,
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent);
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Manage the keyboard inputs to control the movement of a free camera.
  8746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8747. */
  8748. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8749. /**
  8750. * Defines the camera the input is attached to.
  8751. */
  8752. camera: FreeCamera;
  8753. /**
  8754. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8755. */
  8756. keysUp: number[];
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8759. */
  8760. keysUpward: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8763. */
  8764. keysDown: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8767. */
  8768. keysDownward: number[];
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8771. */
  8772. keysLeft: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8775. */
  8776. keysRight: number[];
  8777. private _keys;
  8778. private _onCanvasBlurObserver;
  8779. private _onKeyboardObserver;
  8780. private _engine;
  8781. private _scene;
  8782. /**
  8783. * Attach the input controls to a specific dom element to get the input from.
  8784. * @param element Defines the element the controls should be listened from
  8785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8786. */
  8787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8788. /**
  8789. * Detach the current controls from the specified dom element.
  8790. * @param element Defines the element to stop listening the inputs from
  8791. */
  8792. detachControl(element: Nullable<HTMLElement>): void;
  8793. /**
  8794. * Update the current camera state depending on the inputs that have been used this frame.
  8795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8796. */
  8797. checkInputs(): void;
  8798. /**
  8799. * Gets the class name of the current intput.
  8800. * @returns the class name
  8801. */
  8802. getClassName(): string;
  8803. /** @hidden */
  8804. _onLostFocus(): void;
  8805. /**
  8806. * Get the friendly name associated with the input class.
  8807. * @returns the input friendly name
  8808. */
  8809. getSimpleName(): string;
  8810. }
  8811. }
  8812. declare module BABYLON {
  8813. /**
  8814. * Interface describing all the common properties and methods a shadow light needs to implement.
  8815. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8816. * as well as binding the different shadow properties to the effects.
  8817. */
  8818. export interface IShadowLight extends Light {
  8819. /**
  8820. * The light id in the scene (used in scene.findLighById for instance)
  8821. */
  8822. id: string;
  8823. /**
  8824. * The position the shdow will be casted from.
  8825. */
  8826. position: Vector3;
  8827. /**
  8828. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8829. */
  8830. direction: Vector3;
  8831. /**
  8832. * The transformed position. Position of the light in world space taking parenting in account.
  8833. */
  8834. transformedPosition: Vector3;
  8835. /**
  8836. * The transformed direction. Direction of the light in world space taking parenting in account.
  8837. */
  8838. transformedDirection: Vector3;
  8839. /**
  8840. * The friendly name of the light in the scene.
  8841. */
  8842. name: string;
  8843. /**
  8844. * Defines the shadow projection clipping minimum z value.
  8845. */
  8846. shadowMinZ: number;
  8847. /**
  8848. * Defines the shadow projection clipping maximum z value.
  8849. */
  8850. shadowMaxZ: number;
  8851. /**
  8852. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8853. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8854. */
  8855. computeTransformedInformation(): boolean;
  8856. /**
  8857. * Gets the scene the light belongs to.
  8858. * @returns The scene
  8859. */
  8860. getScene(): Scene;
  8861. /**
  8862. * Callback defining a custom Projection Matrix Builder.
  8863. * This can be used to override the default projection matrix computation.
  8864. */
  8865. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8866. /**
  8867. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8868. * @param matrix The materix to updated with the projection information
  8869. * @param viewMatrix The transform matrix of the light
  8870. * @param renderList The list of mesh to render in the map
  8871. * @returns The current light
  8872. */
  8873. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8874. /**
  8875. * Gets the current depth scale used in ESM.
  8876. * @returns The scale
  8877. */
  8878. getDepthScale(): number;
  8879. /**
  8880. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8881. * @returns true if a cube texture needs to be use
  8882. */
  8883. needCube(): boolean;
  8884. /**
  8885. * Detects if the projection matrix requires to be recomputed this frame.
  8886. * @returns true if it requires to be recomputed otherwise, false.
  8887. */
  8888. needProjectionMatrixCompute(): boolean;
  8889. /**
  8890. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8891. */
  8892. forceProjectionMatrixCompute(): void;
  8893. /**
  8894. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8895. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8896. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8897. */
  8898. getShadowDirection(faceIndex?: number): Vector3;
  8899. /**
  8900. * Gets the minZ used for shadow according to both the scene and the light.
  8901. * @param activeCamera The camera we are returning the min for
  8902. * @returns the depth min z
  8903. */
  8904. getDepthMinZ(activeCamera: Camera): number;
  8905. /**
  8906. * Gets the maxZ used for shadow according to both the scene and the light.
  8907. * @param activeCamera The camera we are returning the max for
  8908. * @returns the depth max z
  8909. */
  8910. getDepthMaxZ(activeCamera: Camera): number;
  8911. }
  8912. /**
  8913. * Base implementation IShadowLight
  8914. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8915. */
  8916. export abstract class ShadowLight extends Light implements IShadowLight {
  8917. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8918. protected _position: Vector3;
  8919. protected _setPosition(value: Vector3): void;
  8920. /**
  8921. * Sets the position the shadow will be casted from. Also use as the light position for both
  8922. * point and spot lights.
  8923. */
  8924. get position(): Vector3;
  8925. /**
  8926. * Sets the position the shadow will be casted from. Also use as the light position for both
  8927. * point and spot lights.
  8928. */
  8929. set position(value: Vector3);
  8930. protected _direction: Vector3;
  8931. protected _setDirection(value: Vector3): void;
  8932. /**
  8933. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8934. * Also use as the light direction on spot and directional lights.
  8935. */
  8936. get direction(): Vector3;
  8937. /**
  8938. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8939. * Also use as the light direction on spot and directional lights.
  8940. */
  8941. set direction(value: Vector3);
  8942. protected _shadowMinZ: number;
  8943. /**
  8944. * Gets the shadow projection clipping minimum z value.
  8945. */
  8946. get shadowMinZ(): number;
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. set shadowMinZ(value: number);
  8951. protected _shadowMaxZ: number;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. get shadowMaxZ(): number;
  8956. /**
  8957. * Gets the shadow projection clipping maximum z value.
  8958. */
  8959. set shadowMaxZ(value: number);
  8960. /**
  8961. * Callback defining a custom Projection Matrix Builder.
  8962. * This can be used to override the default projection matrix computation.
  8963. */
  8964. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8965. /**
  8966. * The transformed position. Position of the light in world space taking parenting in account.
  8967. */
  8968. transformedPosition: Vector3;
  8969. /**
  8970. * The transformed direction. Direction of the light in world space taking parenting in account.
  8971. */
  8972. transformedDirection: Vector3;
  8973. private _needProjectionMatrixCompute;
  8974. /**
  8975. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8976. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8977. */
  8978. computeTransformedInformation(): boolean;
  8979. /**
  8980. * Return the depth scale used for the shadow map.
  8981. * @returns the depth scale.
  8982. */
  8983. getDepthScale(): number;
  8984. /**
  8985. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8986. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8987. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8988. */
  8989. getShadowDirection(faceIndex?: number): Vector3;
  8990. /**
  8991. * Returns the ShadowLight absolute position in the World.
  8992. * @returns the position vector in world space
  8993. */
  8994. getAbsolutePosition(): Vector3;
  8995. /**
  8996. * Sets the ShadowLight direction toward the passed target.
  8997. * @param target The point to target in local space
  8998. * @returns the updated ShadowLight direction
  8999. */
  9000. setDirectionToTarget(target: Vector3): Vector3;
  9001. /**
  9002. * Returns the light rotation in euler definition.
  9003. * @returns the x y z rotation in local space.
  9004. */
  9005. getRotation(): Vector3;
  9006. /**
  9007. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9008. * @returns true if a cube texture needs to be use
  9009. */
  9010. needCube(): boolean;
  9011. /**
  9012. * Detects if the projection matrix requires to be recomputed this frame.
  9013. * @returns true if it requires to be recomputed otherwise, false.
  9014. */
  9015. needProjectionMatrixCompute(): boolean;
  9016. /**
  9017. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9018. */
  9019. forceProjectionMatrixCompute(): void;
  9020. /** @hidden */
  9021. _initCache(): void;
  9022. /** @hidden */
  9023. _isSynchronized(): boolean;
  9024. /**
  9025. * Computes the world matrix of the node
  9026. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9027. * @returns the world matrix
  9028. */
  9029. computeWorldMatrix(force?: boolean): Matrix;
  9030. /**
  9031. * Gets the minZ used for shadow according to both the scene and the light.
  9032. * @param activeCamera The camera we are returning the min for
  9033. * @returns the depth min z
  9034. */
  9035. getDepthMinZ(activeCamera: Camera): number;
  9036. /**
  9037. * Gets the maxZ used for shadow according to both the scene and the light.
  9038. * @param activeCamera The camera we are returning the max for
  9039. * @returns the depth max z
  9040. */
  9041. getDepthMaxZ(activeCamera: Camera): number;
  9042. /**
  9043. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9044. * @param matrix The materix to updated with the projection information
  9045. * @param viewMatrix The transform matrix of the light
  9046. * @param renderList The list of mesh to render in the map
  9047. * @returns The current light
  9048. */
  9049. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9050. }
  9051. }
  9052. declare module BABYLON {
  9053. /**
  9054. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9055. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9056. */
  9057. export class EffectFallbacks implements IEffectFallbacks {
  9058. private _defines;
  9059. private _currentRank;
  9060. private _maxRank;
  9061. private _mesh;
  9062. /**
  9063. * Removes the fallback from the bound mesh.
  9064. */
  9065. unBindMesh(): void;
  9066. /**
  9067. * Adds a fallback on the specified property.
  9068. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9069. * @param define The name of the define in the shader
  9070. */
  9071. addFallback(rank: number, define: string): void;
  9072. /**
  9073. * Sets the mesh to use CPU skinning when needing to fallback.
  9074. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9075. * @param mesh The mesh to use the fallbacks.
  9076. */
  9077. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9078. /**
  9079. * Checks to see if more fallbacks are still availible.
  9080. */
  9081. get hasMoreFallbacks(): boolean;
  9082. /**
  9083. * Removes the defines that should be removed when falling back.
  9084. * @param currentDefines defines the current define statements for the shader.
  9085. * @param effect defines the current effect we try to compile
  9086. * @returns The resulting defines with defines of the current rank removed.
  9087. */
  9088. reduce(currentDefines: string, effect: Effect): string;
  9089. }
  9090. }
  9091. declare module BABYLON {
  9092. /**
  9093. * "Static Class" containing the most commonly used helper while dealing with material for
  9094. * rendering purpose.
  9095. *
  9096. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9097. *
  9098. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9099. */
  9100. export class MaterialHelper {
  9101. /**
  9102. * Bind the current view position to an effect.
  9103. * @param effect The effect to be bound
  9104. * @param scene The scene the eyes position is used from
  9105. */
  9106. static BindEyePosition(effect: Effect, scene: Scene): void;
  9107. /**
  9108. * Helps preparing the defines values about the UVs in used in the effect.
  9109. * UVs are shared as much as we can accross channels in the shaders.
  9110. * @param texture The texture we are preparing the UVs for
  9111. * @param defines The defines to update
  9112. * @param key The channel key "diffuse", "specular"... used in the shader
  9113. */
  9114. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9115. /**
  9116. * Binds a texture matrix value to its corrsponding uniform
  9117. * @param texture The texture to bind the matrix for
  9118. * @param uniformBuffer The uniform buffer receivin the data
  9119. * @param key The channel key "diffuse", "specular"... used in the shader
  9120. */
  9121. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9122. /**
  9123. * Gets the current status of the fog (should it be enabled?)
  9124. * @param mesh defines the mesh to evaluate for fog support
  9125. * @param scene defines the hosting scene
  9126. * @returns true if fog must be enabled
  9127. */
  9128. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9129. /**
  9130. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9131. * @param mesh defines the current mesh
  9132. * @param scene defines the current scene
  9133. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9134. * @param pointsCloud defines if point cloud rendering has to be turned on
  9135. * @param fogEnabled defines if fog has to be turned on
  9136. * @param alphaTest defines if alpha testing has to be turned on
  9137. * @param defines defines the current list of defines
  9138. */
  9139. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9140. /**
  9141. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9142. * @param scene defines the current scene
  9143. * @param engine defines the current engine
  9144. * @param defines specifies the list of active defines
  9145. * @param useInstances defines if instances have to be turned on
  9146. * @param useClipPlane defines if clip plane have to be turned on
  9147. */
  9148. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9149. /**
  9150. * Prepares the defines for bones
  9151. * @param mesh The mesh containing the geometry data we will draw
  9152. * @param defines The defines to update
  9153. */
  9154. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9155. /**
  9156. * Prepares the defines for morph targets
  9157. * @param mesh The mesh containing the geometry data we will draw
  9158. * @param defines The defines to update
  9159. */
  9160. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9161. /**
  9162. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9166. * @param useBones Precise whether bones should be used or not (override mesh info)
  9167. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9168. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9169. * @returns false if defines are considered not dirty and have not been checked
  9170. */
  9171. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9172. /**
  9173. * Prepares the defines related to multiview
  9174. * @param scene The scene we are intending to draw
  9175. * @param defines The defines to update
  9176. */
  9177. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9178. /**
  9179. * Prepares the defines related to the light information passed in parameter
  9180. * @param scene The scene we are intending to draw
  9181. * @param mesh The mesh the effect is compiling for
  9182. * @param light The light the effect is compiling for
  9183. * @param lightIndex The index of the light
  9184. * @param defines The defines to update
  9185. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9186. * @param state Defines the current state regarding what is needed (normals, etc...)
  9187. */
  9188. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9189. needNormals: boolean;
  9190. needRebuild: boolean;
  9191. shadowEnabled: boolean;
  9192. specularEnabled: boolean;
  9193. lightmapMode: boolean;
  9194. }): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param defines The defines to update
  9200. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9201. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9202. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9203. * @returns true if normals will be required for the rest of the effect
  9204. */
  9205. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9208. * @param lightIndex defines the light index
  9209. * @param uniformsList The uniform list
  9210. * @param samplersList The sampler list
  9211. * @param projectedLightTexture defines if projected texture must be used
  9212. * @param uniformBuffersList defines an optional list of uniform buffers
  9213. */
  9214. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect
  9217. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9218. * @param samplersList The sampler list
  9219. * @param defines The defines helping in the list generation
  9220. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9221. */
  9222. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9223. /**
  9224. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9225. * @param defines The defines to update while falling back
  9226. * @param fallbacks The authorized effect fallbacks
  9227. * @param maxSimultaneousLights The maximum number of lights allowed
  9228. * @param rank the current rank of the Effect
  9229. * @returns The newly affected rank
  9230. */
  9231. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9232. private static _TmpMorphInfluencers;
  9233. /**
  9234. * Prepares the list of attributes required for morph targets according to the effect defines.
  9235. * @param attribs The current list of supported attribs
  9236. * @param mesh The mesh to prepare the morph targets attributes for
  9237. * @param influencers The number of influencers
  9238. */
  9239. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9240. /**
  9241. * Prepares the list of attributes required for morph targets according to the effect defines.
  9242. * @param attribs The current list of supported attribs
  9243. * @param mesh The mesh to prepare the morph targets attributes for
  9244. * @param defines The current Defines of the effect
  9245. */
  9246. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9247. /**
  9248. * Prepares the list of attributes required for bones according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param mesh The mesh to prepare the bones attributes for
  9251. * @param defines The current Defines of the effect
  9252. * @param fallbacks The current efffect fallback strategy
  9253. */
  9254. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9255. /**
  9256. * Check and prepare the list of attributes required for instances according to the effect defines.
  9257. * @param attribs The current list of supported attribs
  9258. * @param defines The current MaterialDefines of the effect
  9259. */
  9260. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9261. /**
  9262. * Add the list of attributes required for instances to the attribs array.
  9263. * @param attribs The current list of supported attribs
  9264. */
  9265. static PushAttributesForInstances(attribs: string[]): void;
  9266. /**
  9267. * Binds the light information to the effect.
  9268. * @param light The light containing the generator
  9269. * @param effect The effect we are binding the data to
  9270. * @param lightIndex The light index in the effect used to render
  9271. */
  9272. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9273. /**
  9274. * Binds the lights information from the scene to the effect for the given mesh.
  9275. * @param light Light to bind
  9276. * @param lightIndex Light index
  9277. * @param scene The scene where the light belongs to
  9278. * @param effect The effect we are binding the data to
  9279. * @param useSpecular Defines if specular is supported
  9280. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9281. */
  9282. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9283. /**
  9284. * Binds the lights information from the scene to the effect for the given mesh.
  9285. * @param scene The scene the lights belongs to
  9286. * @param mesh The mesh we are binding the information to render
  9287. * @param effect The effect we are binding the data to
  9288. * @param defines The generated defines for the effect
  9289. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9290. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9291. */
  9292. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9293. private static _tempFogColor;
  9294. /**
  9295. * Binds the fog information from the scene to the effect for the given mesh.
  9296. * @param scene The scene the lights belongs to
  9297. * @param mesh The mesh we are binding the information to render
  9298. * @param effect The effect we are binding the data to
  9299. * @param linearSpace Defines if the fog effect is applied in linear space
  9300. */
  9301. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9302. /**
  9303. * Binds the bones information from the mesh to the effect.
  9304. * @param mesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9308. /**
  9309. * Binds the morph targets information from the mesh to the effect.
  9310. * @param abstractMesh The mesh we are binding the information to render
  9311. * @param effect The effect we are binding the data to
  9312. */
  9313. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9314. /**
  9315. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9316. * @param defines The generated defines used in the effect
  9317. * @param effect The effect we are binding the data to
  9318. * @param scene The scene we are willing to render with logarithmic scale for
  9319. */
  9320. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9321. /**
  9322. * Binds the clip plane information from the scene to the effect.
  9323. * @param scene The scene the clip plane information are extracted from
  9324. * @param effect The effect we are binding the data to
  9325. */
  9326. static BindClipPlane(effect: Effect, scene: Scene): void;
  9327. }
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var packingFunctions: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var clipPlaneFragmentDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var clipPlaneFragment: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var shadowMapPixelShader: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var bonesDeclaration: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var morphTargetsVertexGlobalDeclaration: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var morphTargetsVertexDeclaration: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var instancesDeclaration: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var helperFunctions: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var clipPlaneVertexDeclaration: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var morphTargetsVertex: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /** @hidden */
  9408. export var instancesVertex: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module BABYLON {
  9414. /** @hidden */
  9415. export var bonesVertex: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module BABYLON {
  9421. /** @hidden */
  9422. export var clipPlaneVertex: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module BABYLON {
  9428. /** @hidden */
  9429. export var shadowMapVertexShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module BABYLON {
  9435. /** @hidden */
  9436. export var depthBoxBlurPixelShader: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * Class representing a ray with position and direction
  9444. */
  9445. export class Ray {
  9446. /** origin point */
  9447. origin: Vector3;
  9448. /** direction */
  9449. direction: Vector3;
  9450. /** length of the ray */
  9451. length: number;
  9452. private static readonly TmpVector3;
  9453. private _tmpRay;
  9454. /**
  9455. * Creates a new ray
  9456. * @param origin origin point
  9457. * @param direction direction
  9458. * @param length length of the ray
  9459. */
  9460. constructor(
  9461. /** origin point */
  9462. origin: Vector3,
  9463. /** direction */
  9464. direction: Vector3,
  9465. /** length of the ray */
  9466. length?: number);
  9467. /**
  9468. * Checks if the ray intersects a box
  9469. * @param minimum bound of the box
  9470. * @param maximum bound of the box
  9471. * @param intersectionTreshold extra extend to be added to the box in all direction
  9472. * @returns if the box was hit
  9473. */
  9474. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9475. /**
  9476. * Checks if the ray intersects a box
  9477. * @param box the bounding box to check
  9478. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9479. * @returns if the box was hit
  9480. */
  9481. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9482. /**
  9483. * If the ray hits a sphere
  9484. * @param sphere the bounding sphere to check
  9485. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9486. * @returns true if it hits the sphere
  9487. */
  9488. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9489. /**
  9490. * If the ray hits a triange
  9491. * @param vertex0 triangle vertex
  9492. * @param vertex1 triangle vertex
  9493. * @param vertex2 triangle vertex
  9494. * @returns intersection information if hit
  9495. */
  9496. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9497. /**
  9498. * Checks if ray intersects a plane
  9499. * @param plane the plane to check
  9500. * @returns the distance away it was hit
  9501. */
  9502. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9503. /**
  9504. * Calculate the intercept of a ray on a given axis
  9505. * @param axis to check 'x' | 'y' | 'z'
  9506. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9507. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9508. */
  9509. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9510. /**
  9511. * Checks if ray intersects a mesh
  9512. * @param mesh the mesh to check
  9513. * @param fastCheck if only the bounding box should checked
  9514. * @returns picking info of the intersecton
  9515. */
  9516. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9517. /**
  9518. * Checks if ray intersects a mesh
  9519. * @param meshes the meshes to check
  9520. * @param fastCheck if only the bounding box should checked
  9521. * @param results array to store result in
  9522. * @returns Array of picking infos
  9523. */
  9524. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9525. private _comparePickingInfo;
  9526. private static smallnum;
  9527. private static rayl;
  9528. /**
  9529. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9530. * @param sega the first point of the segment to test the intersection against
  9531. * @param segb the second point of the segment to test the intersection against
  9532. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9533. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9534. */
  9535. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9536. /**
  9537. * Update the ray from viewport position
  9538. * @param x position
  9539. * @param y y position
  9540. * @param viewportWidth viewport width
  9541. * @param viewportHeight viewport height
  9542. * @param world world matrix
  9543. * @param view view matrix
  9544. * @param projection projection matrix
  9545. * @returns this ray updated
  9546. */
  9547. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9548. /**
  9549. * Creates a ray with origin and direction of 0,0,0
  9550. * @returns the new ray
  9551. */
  9552. static Zero(): Ray;
  9553. /**
  9554. * Creates a new ray from screen space and viewport
  9555. * @param x position
  9556. * @param y y position
  9557. * @param viewportWidth viewport width
  9558. * @param viewportHeight viewport height
  9559. * @param world world matrix
  9560. * @param view view matrix
  9561. * @param projection projection matrix
  9562. * @returns new ray
  9563. */
  9564. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9565. /**
  9566. * 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
  9567. * transformed to the given world matrix.
  9568. * @param origin The origin point
  9569. * @param end The end point
  9570. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9571. * @returns the new ray
  9572. */
  9573. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * Transforms a ray by a matrix
  9576. * @param ray ray to transform
  9577. * @param matrix matrix to apply
  9578. * @returns the resulting new ray
  9579. */
  9580. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9581. /**
  9582. * Transforms a ray by a matrix
  9583. * @param ray ray to transform
  9584. * @param matrix matrix to apply
  9585. * @param result ray to store result in
  9586. */
  9587. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9588. /**
  9589. * Unproject a ray from screen space to object space
  9590. * @param sourceX defines the screen space x coordinate to use
  9591. * @param sourceY defines the screen space y coordinate to use
  9592. * @param viewportWidth defines the current width of the viewport
  9593. * @param viewportHeight defines the current height of the viewport
  9594. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9595. * @param view defines the view matrix to use
  9596. * @param projection defines the projection matrix to use
  9597. */
  9598. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9599. }
  9600. /**
  9601. * Type used to define predicate used to select faces when a mesh intersection is detected
  9602. */
  9603. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9604. interface Scene {
  9605. /** @hidden */
  9606. _tempPickingRay: Nullable<Ray>;
  9607. /** @hidden */
  9608. _cachedRayForTransform: Ray;
  9609. /** @hidden */
  9610. _pickWithRayInverseMatrix: Matrix;
  9611. /** @hidden */
  9612. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9613. /** @hidden */
  9614. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9615. }
  9616. }
  9617. declare module BABYLON {
  9618. /**
  9619. * Groups all the scene component constants in one place to ease maintenance.
  9620. * @hidden
  9621. */
  9622. export class SceneComponentConstants {
  9623. static readonly NAME_EFFECTLAYER: string;
  9624. static readonly NAME_LAYER: string;
  9625. static readonly NAME_LENSFLARESYSTEM: string;
  9626. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9627. static readonly NAME_PARTICLESYSTEM: string;
  9628. static readonly NAME_GAMEPAD: string;
  9629. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9630. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9631. static readonly NAME_DEPTHRENDERER: string;
  9632. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9633. static readonly NAME_SPRITE: string;
  9634. static readonly NAME_OUTLINERENDERER: string;
  9635. static readonly NAME_PROCEDURALTEXTURE: string;
  9636. static readonly NAME_SHADOWGENERATOR: string;
  9637. static readonly NAME_OCTREE: string;
  9638. static readonly NAME_PHYSICSENGINE: string;
  9639. static readonly NAME_AUDIO: string;
  9640. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9641. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9644. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9646. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9648. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9651. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9653. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9654. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9655. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9657. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9658. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9659. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9660. static readonly STEP_AFTERRENDER_AUDIO: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9664. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9665. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9666. static readonly STEP_POINTERMOVE_SPRITE: number;
  9667. static readonly STEP_POINTERDOWN_SPRITE: number;
  9668. static readonly STEP_POINTERUP_SPRITE: number;
  9669. }
  9670. /**
  9671. * This represents a scene component.
  9672. *
  9673. * This is used to decouple the dependency the scene is having on the different workloads like
  9674. * layers, post processes...
  9675. */
  9676. export interface ISceneComponent {
  9677. /**
  9678. * The name of the component. Each component must have a unique name.
  9679. */
  9680. name: string;
  9681. /**
  9682. * The scene the component belongs to.
  9683. */
  9684. scene: Scene;
  9685. /**
  9686. * Register the component to one instance of a scene.
  9687. */
  9688. register(): void;
  9689. /**
  9690. * Rebuilds the elements related to this component in case of
  9691. * context lost for instance.
  9692. */
  9693. rebuild(): void;
  9694. /**
  9695. * Disposes the component and the associated ressources.
  9696. */
  9697. dispose(): void;
  9698. }
  9699. /**
  9700. * This represents a SERIALIZABLE scene component.
  9701. *
  9702. * This extends Scene Component to add Serialization methods on top.
  9703. */
  9704. export interface ISceneSerializableComponent extends ISceneComponent {
  9705. /**
  9706. * Adds all the elements from the container to the scene
  9707. * @param container the container holding the elements
  9708. */
  9709. addFromContainer(container: AbstractScene): void;
  9710. /**
  9711. * Removes all the elements in the container from the scene
  9712. * @param container contains the elements to remove
  9713. * @param dispose if the removed element should be disposed (default: false)
  9714. */
  9715. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9716. /**
  9717. * Serializes the component data to the specified json object
  9718. * @param serializationObject The object to serialize to
  9719. */
  9720. serialize(serializationObject: any): void;
  9721. }
  9722. /**
  9723. * Strong typing of a Mesh related stage step action
  9724. */
  9725. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9726. /**
  9727. * Strong typing of a Evaluate Sub Mesh related stage step action
  9728. */
  9729. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9730. /**
  9731. * Strong typing of a Active Mesh related stage step action
  9732. */
  9733. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9734. /**
  9735. * Strong typing of a Camera related stage step action
  9736. */
  9737. export type CameraStageAction = (camera: Camera) => void;
  9738. /**
  9739. * Strong typing of a Camera Frame buffer related stage step action
  9740. */
  9741. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9742. /**
  9743. * Strong typing of a Render Target related stage step action
  9744. */
  9745. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9746. /**
  9747. * Strong typing of a RenderingGroup related stage step action
  9748. */
  9749. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9750. /**
  9751. * Strong typing of a Mesh Render related stage step action
  9752. */
  9753. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9754. /**
  9755. * Strong typing of a simple stage step action
  9756. */
  9757. export type SimpleStageAction = () => void;
  9758. /**
  9759. * Strong typing of a render target action.
  9760. */
  9761. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9762. /**
  9763. * Strong typing of a pointer move action.
  9764. */
  9765. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9766. /**
  9767. * Strong typing of a pointer up/down action.
  9768. */
  9769. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9770. /**
  9771. * Representation of a stage in the scene (Basically a list of ordered steps)
  9772. * @hidden
  9773. */
  9774. export class Stage<T extends Function> extends Array<{
  9775. index: number;
  9776. component: ISceneComponent;
  9777. action: T;
  9778. }> {
  9779. /**
  9780. * Hide ctor from the rest of the world.
  9781. * @param items The items to add.
  9782. */
  9783. private constructor();
  9784. /**
  9785. * Creates a new Stage.
  9786. * @returns A new instance of a Stage
  9787. */
  9788. static Create<T extends Function>(): Stage<T>;
  9789. /**
  9790. * Registers a step in an ordered way in the targeted stage.
  9791. * @param index Defines the position to register the step in
  9792. * @param component Defines the component attached to the step
  9793. * @param action Defines the action to launch during the step
  9794. */
  9795. registerStep(index: number, component: ISceneComponent, action: T): void;
  9796. /**
  9797. * Clears all the steps from the stage.
  9798. */
  9799. clear(): void;
  9800. }
  9801. }
  9802. declare module BABYLON {
  9803. interface Scene {
  9804. /** @hidden */
  9805. _pointerOverSprite: Nullable<Sprite>;
  9806. /** @hidden */
  9807. _pickedDownSprite: Nullable<Sprite>;
  9808. /** @hidden */
  9809. _tempSpritePickingRay: Nullable<Ray>;
  9810. /**
  9811. * All of the sprite managers added to this scene
  9812. * @see http://doc.babylonjs.com/babylon101/sprites
  9813. */
  9814. spriteManagers: Array<ISpriteManager>;
  9815. /**
  9816. * An event triggered when sprites rendering is about to start
  9817. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9818. */
  9819. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9820. /**
  9821. * An event triggered when sprites rendering is done
  9822. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9823. */
  9824. onAfterSpritesRenderingObservable: Observable<Scene>;
  9825. /** @hidden */
  9826. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9827. /** Launch a ray to try to pick a sprite 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 fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9832. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9833. * @returns a PickingInfo
  9834. */
  9835. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Use the given ray to pick a sprite in the scene
  9837. * @param ray The ray (in world space) to use to pick meshes
  9838. * @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
  9839. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9840. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9841. * @returns a PickingInfo
  9842. */
  9843. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9844. /** @hidden */
  9845. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9846. /** Launch a ray to try to pick sprites in the scene
  9847. * @param x position on screen
  9848. * @param y position on screen
  9849. * @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
  9850. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9851. * @returns a PickingInfo array
  9852. */
  9853. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9854. /** Use the given ray to pick sprites in the scene
  9855. * @param ray The ray (in world space) to use to pick meshes
  9856. * @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
  9857. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9858. * @returns a PickingInfo array
  9859. */
  9860. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9861. /**
  9862. * Force the sprite under the pointer
  9863. * @param sprite defines the sprite to use
  9864. */
  9865. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9866. /**
  9867. * Gets the sprite under the pointer
  9868. * @returns a Sprite or null if no sprite is under the pointer
  9869. */
  9870. getPointerOverSprite(): Nullable<Sprite>;
  9871. }
  9872. /**
  9873. * Defines the sprite scene component responsible to manage sprites
  9874. * in a given scene.
  9875. */
  9876. export class SpriteSceneComponent implements ISceneComponent {
  9877. /**
  9878. * The component name helpfull to identify the component in the list of scene components.
  9879. */
  9880. readonly name: string;
  9881. /**
  9882. * The scene the component belongs to.
  9883. */
  9884. scene: Scene;
  9885. /** @hidden */
  9886. private _spritePredicate;
  9887. /**
  9888. * Creates a new instance of the component for the given scene
  9889. * @param scene Defines the scene to register the component in
  9890. */
  9891. constructor(scene: Scene);
  9892. /**
  9893. * Registers the component in a given scene
  9894. */
  9895. register(): void;
  9896. /**
  9897. * Rebuilds the elements related to this component in case of
  9898. * context lost for instance.
  9899. */
  9900. rebuild(): void;
  9901. /**
  9902. * Disposes the component and the associated ressources.
  9903. */
  9904. dispose(): void;
  9905. private _pickSpriteButKeepRay;
  9906. private _pointerMove;
  9907. private _pointerDown;
  9908. private _pointerUp;
  9909. }
  9910. }
  9911. declare module BABYLON {
  9912. /** @hidden */
  9913. export var fogFragmentDeclaration: {
  9914. name: string;
  9915. shader: string;
  9916. };
  9917. }
  9918. declare module BABYLON {
  9919. /** @hidden */
  9920. export var fogFragment: {
  9921. name: string;
  9922. shader: string;
  9923. };
  9924. }
  9925. declare module BABYLON {
  9926. /** @hidden */
  9927. export var spritesPixelShader: {
  9928. name: string;
  9929. shader: string;
  9930. };
  9931. }
  9932. declare module BABYLON {
  9933. /** @hidden */
  9934. export var fogVertexDeclaration: {
  9935. name: string;
  9936. shader: string;
  9937. };
  9938. }
  9939. declare module BABYLON {
  9940. /** @hidden */
  9941. export var spritesVertexShader: {
  9942. name: string;
  9943. shader: string;
  9944. };
  9945. }
  9946. declare module BABYLON {
  9947. /**
  9948. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9949. */
  9950. export interface ISpriteManager extends IDisposable {
  9951. /**
  9952. * Restricts the camera to viewing objects with the same layerMask.
  9953. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9954. */
  9955. layerMask: number;
  9956. /**
  9957. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9958. */
  9959. isPickable: boolean;
  9960. /**
  9961. * Specifies the rendering group id for this mesh (0 by default)
  9962. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9963. */
  9964. renderingGroupId: number;
  9965. /**
  9966. * Defines the list of sprites managed by the manager.
  9967. */
  9968. sprites: Array<Sprite>;
  9969. /**
  9970. * Tests the intersection of a sprite with a specific ray.
  9971. * @param ray The ray we are sending to test the collision
  9972. * @param camera The camera space we are sending rays in
  9973. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9974. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9975. * @returns picking info or null.
  9976. */
  9977. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9978. /**
  9979. * Intersects the sprites with a ray
  9980. * @param ray defines the ray to intersect with
  9981. * @param camera defines the current active camera
  9982. * @param predicate defines a predicate used to select candidate sprites
  9983. * @returns null if no hit or a PickingInfo array
  9984. */
  9985. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9986. /**
  9987. * Renders the list of sprites on screen.
  9988. */
  9989. render(): void;
  9990. }
  9991. /**
  9992. * Class used to manage multiple sprites on the same spritesheet
  9993. * @see http://doc.babylonjs.com/babylon101/sprites
  9994. */
  9995. export class SpriteManager implements ISpriteManager {
  9996. /** defines the manager's name */
  9997. name: string;
  9998. /** Gets the list of sprites */
  9999. sprites: Sprite[];
  10000. /** Gets or sets the rendering group id (0 by default) */
  10001. renderingGroupId: number;
  10002. /** Gets or sets camera layer mask */
  10003. layerMask: number;
  10004. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10005. fogEnabled: boolean;
  10006. /** Gets or sets a boolean indicating if the sprites are pickable */
  10007. isPickable: boolean;
  10008. /** Defines the default width of a cell in the spritesheet */
  10009. cellWidth: number;
  10010. /** Defines the default height of a cell in the spritesheet */
  10011. cellHeight: number;
  10012. /** Associative array from JSON sprite data file */
  10013. private _cellData;
  10014. /** Array of sprite names from JSON sprite data file */
  10015. private _spriteMap;
  10016. /** True when packed cell data from JSON file is ready*/
  10017. private _packedAndReady;
  10018. /**
  10019. * An event triggered when the manager is disposed.
  10020. */
  10021. onDisposeObservable: Observable<SpriteManager>;
  10022. private _onDisposeObserver;
  10023. /**
  10024. * Callback called when the manager is disposed
  10025. */
  10026. set onDispose(callback: () => void);
  10027. private _capacity;
  10028. private _fromPacked;
  10029. private _spriteTexture;
  10030. private _epsilon;
  10031. private _scene;
  10032. private _vertexData;
  10033. private _buffer;
  10034. private _vertexBuffers;
  10035. private _indexBuffer;
  10036. private _effectBase;
  10037. private _effectFog;
  10038. /**
  10039. * Gets or sets the spritesheet texture
  10040. */
  10041. get texture(): Texture;
  10042. set texture(value: Texture);
  10043. private _blendMode;
  10044. /**
  10045. * Blend mode use to render the particle, it can be any of
  10046. * the static Constants.ALPHA_x properties provided in this class.
  10047. * Default value is Constants.ALPHA_COMBINE
  10048. */
  10049. get blendMode(): number;
  10050. set blendMode(blendMode: number);
  10051. /** Disables writing to the depth buffer when rendering the sprites.
  10052. * It can be handy to disable depth writing when using textures without alpha channel
  10053. * and setting some specific blend modes.
  10054. */
  10055. disableDepthWrite: boolean;
  10056. /**
  10057. * Creates a new sprite manager
  10058. * @param name defines the manager's name
  10059. * @param imgUrl defines the sprite sheet url
  10060. * @param capacity defines the maximum allowed number of sprites
  10061. * @param cellSize defines the size of a sprite cell
  10062. * @param scene defines the hosting scene
  10063. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10064. * @param samplingMode defines the smapling mode to use with spritesheet
  10065. * @param fromPacked set to false; do not alter
  10066. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10067. */
  10068. constructor(
  10069. /** defines the manager's name */
  10070. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10071. private _makePacked;
  10072. private _appendSpriteVertex;
  10073. /**
  10074. * Intersects the sprites with a ray
  10075. * @param ray defines the ray to intersect with
  10076. * @param camera defines the current active camera
  10077. * @param predicate defines a predicate used to select candidate sprites
  10078. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10079. * @returns null if no hit or a PickingInfo
  10080. */
  10081. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10082. /**
  10083. * Intersects the sprites with a ray
  10084. * @param ray defines the ray to intersect with
  10085. * @param camera defines the current active camera
  10086. * @param predicate defines a predicate used to select candidate sprites
  10087. * @returns null if no hit or a PickingInfo array
  10088. */
  10089. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10090. /**
  10091. * Render all child sprites
  10092. */
  10093. render(): void;
  10094. /**
  10095. * Release associated resources
  10096. */
  10097. dispose(): void;
  10098. }
  10099. }
  10100. declare module BABYLON {
  10101. /** Interface used by value gradients (color, factor, ...) */
  10102. export interface IValueGradient {
  10103. /**
  10104. * Gets or sets the gradient value (between 0 and 1)
  10105. */
  10106. gradient: number;
  10107. }
  10108. /** Class used to store color4 gradient */
  10109. export class ColorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated color
  10116. */
  10117. color1: Color4;
  10118. /**
  10119. * Gets or sets second associated color
  10120. */
  10121. color2?: Color4 | undefined;
  10122. /**
  10123. * Creates a new color4 gradient
  10124. * @param gradient gets or sets the gradient value (between 0 and 1)
  10125. * @param color1 gets or sets first associated color
  10126. * @param color2 gets or sets first second color
  10127. */
  10128. constructor(
  10129. /**
  10130. * Gets or sets the gradient value (between 0 and 1)
  10131. */
  10132. gradient: number,
  10133. /**
  10134. * Gets or sets first associated color
  10135. */
  10136. color1: Color4,
  10137. /**
  10138. * Gets or sets second associated color
  10139. */
  10140. color2?: Color4 | undefined);
  10141. /**
  10142. * Will get a color picked randomly between color1 and color2.
  10143. * If color2 is undefined then color1 will be used
  10144. * @param result defines the target Color4 to store the result in
  10145. */
  10146. getColorToRef(result: Color4): void;
  10147. }
  10148. /** Class used to store color 3 gradient */
  10149. export class Color3Gradient implements IValueGradient {
  10150. /**
  10151. * Gets or sets the gradient value (between 0 and 1)
  10152. */
  10153. gradient: number;
  10154. /**
  10155. * Gets or sets the associated color
  10156. */
  10157. color: Color3;
  10158. /**
  10159. * Creates a new color3 gradient
  10160. * @param gradient gets or sets the gradient value (between 0 and 1)
  10161. * @param color gets or sets associated color
  10162. */
  10163. constructor(
  10164. /**
  10165. * Gets or sets the gradient value (between 0 and 1)
  10166. */
  10167. gradient: number,
  10168. /**
  10169. * Gets or sets the associated color
  10170. */
  10171. color: Color3);
  10172. }
  10173. /** Class used to store factor gradient */
  10174. export class FactorGradient implements IValueGradient {
  10175. /**
  10176. * Gets or sets the gradient value (between 0 and 1)
  10177. */
  10178. gradient: number;
  10179. /**
  10180. * Gets or sets first associated factor
  10181. */
  10182. factor1: number;
  10183. /**
  10184. * Gets or sets second associated factor
  10185. */
  10186. factor2?: number | undefined;
  10187. /**
  10188. * Creates a new factor gradient
  10189. * @param gradient gets or sets the gradient value (between 0 and 1)
  10190. * @param factor1 gets or sets first associated factor
  10191. * @param factor2 gets or sets second associated factor
  10192. */
  10193. constructor(
  10194. /**
  10195. * Gets or sets the gradient value (between 0 and 1)
  10196. */
  10197. gradient: number,
  10198. /**
  10199. * Gets or sets first associated factor
  10200. */
  10201. factor1: number,
  10202. /**
  10203. * Gets or sets second associated factor
  10204. */
  10205. factor2?: number | undefined);
  10206. /**
  10207. * Will get a number picked randomly between factor1 and factor2.
  10208. * If factor2 is undefined then factor1 will be used
  10209. * @returns the picked number
  10210. */
  10211. getFactor(): number;
  10212. }
  10213. /**
  10214. * Helper used to simplify some generic gradient tasks
  10215. */
  10216. export class GradientHelper {
  10217. /**
  10218. * Gets the current gradient from an array of IValueGradient
  10219. * @param ratio defines the current ratio to get
  10220. * @param gradients defines the array of IValueGradient
  10221. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10222. */
  10223. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Interface for the size containing width and height
  10229. */
  10230. export interface ISize {
  10231. /**
  10232. * Width
  10233. */
  10234. width: number;
  10235. /**
  10236. * Heighht
  10237. */
  10238. height: number;
  10239. }
  10240. /**
  10241. * Size containing widht and height
  10242. */
  10243. export class Size implements ISize {
  10244. /**
  10245. * Width
  10246. */
  10247. width: number;
  10248. /**
  10249. * Height
  10250. */
  10251. height: number;
  10252. /**
  10253. * Creates a Size object from the given width and height (floats).
  10254. * @param width width of the new size
  10255. * @param height height of the new size
  10256. */
  10257. constructor(width: number, height: number);
  10258. /**
  10259. * Returns a string with the Size width and height
  10260. * @returns a string with the Size width and height
  10261. */
  10262. toString(): string;
  10263. /**
  10264. * "Size"
  10265. * @returns the string "Size"
  10266. */
  10267. getClassName(): string;
  10268. /**
  10269. * Returns the Size hash code.
  10270. * @returns a hash code for a unique width and height
  10271. */
  10272. getHashCode(): number;
  10273. /**
  10274. * Updates the current size from the given one.
  10275. * @param src the given size
  10276. */
  10277. copyFrom(src: Size): void;
  10278. /**
  10279. * Updates in place the current Size from the given floats.
  10280. * @param width width of the new size
  10281. * @param height height of the new size
  10282. * @returns the updated Size.
  10283. */
  10284. copyFromFloats(width: number, height: number): Size;
  10285. /**
  10286. * Updates in place the current Size from the given floats.
  10287. * @param width width to set
  10288. * @param height height to set
  10289. * @returns the updated Size.
  10290. */
  10291. set(width: number, height: number): Size;
  10292. /**
  10293. * Multiplies the width and height by numbers
  10294. * @param w factor to multiple the width by
  10295. * @param h factor to multiple the height by
  10296. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10297. */
  10298. multiplyByFloats(w: number, h: number): Size;
  10299. /**
  10300. * Clones the size
  10301. * @returns a new Size copied from the given one.
  10302. */
  10303. clone(): Size;
  10304. /**
  10305. * True if the current Size and the given one width and height are strictly equal.
  10306. * @param other the other size to compare against
  10307. * @returns True if the current Size and the given one width and height are strictly equal.
  10308. */
  10309. equals(other: Size): boolean;
  10310. /**
  10311. * The surface of the Size : width * height (float).
  10312. */
  10313. get surface(): number;
  10314. /**
  10315. * Create a new size of zero
  10316. * @returns a new Size set to (0.0, 0.0)
  10317. */
  10318. static Zero(): Size;
  10319. /**
  10320. * Sums the width and height of two sizes
  10321. * @param otherSize size to add to this size
  10322. * @returns a new Size set as the addition result of the current Size and the given one.
  10323. */
  10324. add(otherSize: Size): Size;
  10325. /**
  10326. * Subtracts the width and height of two
  10327. * @param otherSize size to subtract to this size
  10328. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10329. */
  10330. subtract(otherSize: Size): Size;
  10331. /**
  10332. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10333. * @param start starting size to lerp between
  10334. * @param end end size to lerp between
  10335. * @param amount amount to lerp between the start and end values
  10336. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10337. */
  10338. static Lerp(start: Size, end: Size, amount: number): Size;
  10339. }
  10340. }
  10341. declare module BABYLON {
  10342. interface ThinEngine {
  10343. /**
  10344. * Creates a dynamic texture
  10345. * @param width defines the width of the texture
  10346. * @param height defines the height of the texture
  10347. * @param generateMipMaps defines if the engine should generate the mip levels
  10348. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10349. * @returns the dynamic texture inside an InternalTexture
  10350. */
  10351. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10352. /**
  10353. * Update the content of a dynamic texture
  10354. * @param texture defines the texture to update
  10355. * @param canvas defines the canvas containing the source
  10356. * @param invertY defines if data must be stored with Y axis inverted
  10357. * @param premulAlpha defines if alpha is stored as premultiplied
  10358. * @param format defines the format of the data
  10359. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10360. */
  10361. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10362. }
  10363. }
  10364. declare module BABYLON {
  10365. /**
  10366. * Helper class used to generate a canvas to manipulate images
  10367. */
  10368. export class CanvasGenerator {
  10369. /**
  10370. * Create a new canvas (or offscreen canvas depending on the context)
  10371. * @param width defines the expected width
  10372. * @param height defines the expected height
  10373. * @return a new canvas or offscreen canvas
  10374. */
  10375. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10376. }
  10377. }
  10378. declare module BABYLON {
  10379. /**
  10380. * A class extending Texture allowing drawing on a texture
  10381. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10382. */
  10383. export class DynamicTexture extends Texture {
  10384. private _generateMipMaps;
  10385. private _canvas;
  10386. private _context;
  10387. private _engine;
  10388. /**
  10389. * Creates a DynamicTexture
  10390. * @param name defines the name of the texture
  10391. * @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
  10392. * @param scene defines the scene where you want the texture
  10393. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10394. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10395. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10396. */
  10397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10398. /**
  10399. * Get the current class name of the texture useful for serialization or dynamic coding.
  10400. * @returns "DynamicTexture"
  10401. */
  10402. getClassName(): string;
  10403. /**
  10404. * Gets the current state of canRescale
  10405. */
  10406. get canRescale(): boolean;
  10407. private _recreate;
  10408. /**
  10409. * Scales the texture
  10410. * @param ratio the scale factor to apply to both width and height
  10411. */
  10412. scale(ratio: number): void;
  10413. /**
  10414. * Resizes the texture
  10415. * @param width the new width
  10416. * @param height the new height
  10417. */
  10418. scaleTo(width: number, height: number): void;
  10419. /**
  10420. * Gets the context of the canvas used by the texture
  10421. * @returns the canvas context of the dynamic texture
  10422. */
  10423. getContext(): CanvasRenderingContext2D;
  10424. /**
  10425. * Clears the texture
  10426. */
  10427. clear(): void;
  10428. /**
  10429. * Updates the texture
  10430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10432. */
  10433. update(invertY?: boolean, premulAlpha?: boolean): void;
  10434. /**
  10435. * Draws text onto the texture
  10436. * @param text defines the text to be drawn
  10437. * @param x defines the placement of the text from the left
  10438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10439. * @param font defines the font to be used with font-style, font-size, font-name
  10440. * @param color defines the color used for the text
  10441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10443. * @param update defines whether texture is immediately update (default is true)
  10444. */
  10445. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10446. /**
  10447. * Clones the texture
  10448. * @returns the clone of the texture.
  10449. */
  10450. clone(): DynamicTexture;
  10451. /**
  10452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10453. * @returns a serialized dynamic texture object
  10454. */
  10455. serialize(): any;
  10456. /** @hidden */
  10457. _rebuild(): void;
  10458. }
  10459. }
  10460. declare module BABYLON {
  10461. interface Engine {
  10462. /**
  10463. * Creates a raw texture
  10464. * @param data defines the data to store in the texture
  10465. * @param width defines the width of the texture
  10466. * @param height defines the height of the texture
  10467. * @param format defines the format of the data
  10468. * @param generateMipMaps defines if the engine should generate the mip levels
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10471. * @param compression defines the compression used (null by default)
  10472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10473. * @returns the raw texture inside an InternalTexture
  10474. */
  10475. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10476. /**
  10477. * Update a raw texture
  10478. * @param texture defines the texture to update
  10479. * @param data defines the data to store in the texture
  10480. * @param format defines the format of the data
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. */
  10483. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10484. /**
  10485. * Update a raw texture
  10486. * @param texture defines the texture to update
  10487. * @param data defines the data to store in the texture
  10488. * @param format defines the format of the data
  10489. * @param invertY defines if data must be stored with Y axis inverted
  10490. * @param compression defines the compression used (null by default)
  10491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10492. */
  10493. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10494. /**
  10495. * Creates a new raw cube texture
  10496. * @param data defines the array of data to use to create each face
  10497. * @param size defines the size of the textures
  10498. * @param format defines the format of the data
  10499. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10500. * @param generateMipMaps defines if the engine should generate the 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 compression used (null by default)
  10504. * @returns the cube texture as an InternalTexture
  10505. */
  10506. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10507. /**
  10508. * Update a raw cube texture
  10509. * @param texture defines the texture to udpdate
  10510. * @param data defines the data to store
  10511. * @param format defines the data format
  10512. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. */
  10515. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10516. /**
  10517. * Update a raw cube texture
  10518. * @param texture defines the texture to udpdate
  10519. * @param data defines the data to store
  10520. * @param format defines the data format
  10521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10522. * @param invertY defines if data must be stored with Y axis inverted
  10523. * @param compression defines the compression used (null by default)
  10524. */
  10525. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10526. /**
  10527. * Update a raw cube texture
  10528. * @param texture defines the texture to udpdate
  10529. * @param data defines the data to store
  10530. * @param format defines the data format
  10531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10532. * @param invertY defines if data must be stored with Y axis inverted
  10533. * @param compression defines the compression used (null by default)
  10534. * @param level defines which level of the texture to update
  10535. */
  10536. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10537. /**
  10538. * Creates a new raw cube texture from a specified url
  10539. * @param url defines the url where the data is located
  10540. * @param scene defines the current scene
  10541. * @param size defines the size of the textures
  10542. * @param format defines the format of the data
  10543. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10544. * @param noMipmap defines if the engine should avoid generating the mip levels
  10545. * @param callback defines a callback used to extract texture data from loaded data
  10546. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10547. * @param onLoad defines a callback called when texture is loaded
  10548. * @param onError defines a callback called if there is an error
  10549. * @returns the cube texture as an InternalTexture
  10550. */
  10551. 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;
  10552. /**
  10553. * Creates a new raw cube texture from a specified url
  10554. * @param url defines the url where the data is located
  10555. * @param scene defines the current scene
  10556. * @param size defines the size of the textures
  10557. * @param format defines the format of the data
  10558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10559. * @param noMipmap defines if the engine should avoid generating the mip levels
  10560. * @param callback defines a callback used to extract texture data from loaded data
  10561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10562. * @param onLoad defines a callback called when texture is loaded
  10563. * @param onError defines a callback called if there is an error
  10564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10565. * @param invertY defines if data must be stored with Y axis inverted
  10566. * @returns the cube texture as an InternalTexture
  10567. */
  10568. 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;
  10569. /**
  10570. * Creates a new raw 3D texture
  10571. * @param data defines the data used to create the texture
  10572. * @param width defines the width of the texture
  10573. * @param height defines the height of the texture
  10574. * @param depth defines the depth of the texture
  10575. * @param format defines the format of the texture
  10576. * @param generateMipMaps defines if the engine must generate mip levels
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10579. * @param compression defines the compressed used (can be null)
  10580. * @param textureType defines the compressed used (can be null)
  10581. * @returns a new raw 3D texture (stored in an InternalTexture)
  10582. */
  10583. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10584. /**
  10585. * Update a raw 3D texture
  10586. * @param texture defines the texture to update
  10587. * @param data defines the data to store
  10588. * @param format defines the data format
  10589. * @param invertY defines if data must be stored with Y axis inverted
  10590. */
  10591. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10592. /**
  10593. * Update a raw 3D texture
  10594. * @param texture defines the texture to update
  10595. * @param data defines the data to store
  10596. * @param format defines the data format
  10597. * @param invertY defines if data must be stored with Y axis inverted
  10598. * @param compression defines the used compression (can be null)
  10599. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10600. */
  10601. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10602. /**
  10603. * Creates a new raw 2D array texture
  10604. * @param data defines the data used to create the texture
  10605. * @param width defines the width of the texture
  10606. * @param height defines the height of the texture
  10607. * @param depth defines the number of layers of the texture
  10608. * @param format defines the format of the texture
  10609. * @param generateMipMaps defines if the engine must generate mip levels
  10610. * @param invertY defines if data must be stored with Y axis inverted
  10611. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10612. * @param compression defines the compressed used (can be null)
  10613. * @param textureType defines the compressed used (can be null)
  10614. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10615. */
  10616. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10617. /**
  10618. * Update a raw 2D array texture
  10619. * @param texture defines the texture to update
  10620. * @param data defines the data to store
  10621. * @param format defines the data format
  10622. * @param invertY defines if data must be stored with Y axis inverted
  10623. */
  10624. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10625. /**
  10626. * Update a raw 2D array texture
  10627. * @param texture defines the texture to update
  10628. * @param data defines the data to store
  10629. * @param format defines the data format
  10630. * @param invertY defines if data must be stored with Y axis inverted
  10631. * @param compression defines the used compression (can be null)
  10632. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10633. */
  10634. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10635. }
  10636. }
  10637. declare module BABYLON {
  10638. /**
  10639. * Raw texture can help creating a texture directly from an array of data.
  10640. * This can be super useful if you either get the data from an uncompressed source or
  10641. * if you wish to create your texture pixel by pixel.
  10642. */
  10643. export class RawTexture extends Texture {
  10644. /**
  10645. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10646. */
  10647. format: number;
  10648. private _engine;
  10649. /**
  10650. * Instantiates a new RawTexture.
  10651. * Raw texture can help creating a texture directly from an array of data.
  10652. * This can be super useful if you either get the data from an uncompressed source or
  10653. * if you wish to create your texture pixel by pixel.
  10654. * @param data define the array of data to use to create the texture
  10655. * @param width define the width of the texture
  10656. * @param height define the height of the texture
  10657. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10658. * @param scene define the scene the texture belongs to
  10659. * @param generateMipMaps define whether mip maps should be generated or not
  10660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10662. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10663. */
  10664. constructor(data: ArrayBufferView, width: number, height: number,
  10665. /**
  10666. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10667. */
  10668. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10669. /**
  10670. * Updates the texture underlying data.
  10671. * @param data Define the new data of the texture
  10672. */
  10673. update(data: ArrayBufferView): void;
  10674. /**
  10675. * Creates a luminance texture from some data.
  10676. * @param data Define the texture data
  10677. * @param width Define the width of the texture
  10678. * @param height Define the height of the texture
  10679. * @param scene Define the scene the texture belongs to
  10680. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10681. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10682. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10683. * @returns the luminance texture
  10684. */
  10685. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10686. /**
  10687. * Creates a luminance alpha texture from some data.
  10688. * @param data Define the texture data
  10689. * @param width Define the width of the texture
  10690. * @param height Define the height of the texture
  10691. * @param scene Define the scene the texture belongs to
  10692. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10693. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10694. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10695. * @returns the luminance alpha texture
  10696. */
  10697. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10698. /**
  10699. * Creates an alpha texture from some data.
  10700. * @param data Define the texture data
  10701. * @param width Define the width of the texture
  10702. * @param height Define the height of the texture
  10703. * @param scene Define the scene the texture belongs to
  10704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10707. * @returns the alpha texture
  10708. */
  10709. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10710. /**
  10711. * Creates a RGB texture from some data.
  10712. * @param data Define the texture data
  10713. * @param width Define the width of the texture
  10714. * @param height Define the height of the texture
  10715. * @param scene Define the scene the texture belongs to
  10716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10720. * @returns the RGB alpha texture
  10721. */
  10722. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10723. /**
  10724. * Creates a RGBA texture from some data.
  10725. * @param data Define the texture data
  10726. * @param width Define the width of the texture
  10727. * @param height Define the height of the texture
  10728. * @param scene Define the scene the texture belongs to
  10729. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10730. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10731. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10732. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10733. * @returns the RGBA texture
  10734. */
  10735. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10736. /**
  10737. * Creates a R texture from some data.
  10738. * @param data Define the texture data
  10739. * @param width Define the width of the texture
  10740. * @param height Define the height of the texture
  10741. * @param scene Define the scene the texture belongs to
  10742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10745. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10746. * @returns the R texture
  10747. */
  10748. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. interface AbstractScene {
  10753. /**
  10754. * The list of procedural textures added to the scene
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10756. */
  10757. proceduralTextures: Array<ProceduralTexture>;
  10758. }
  10759. /**
  10760. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10761. * in a given scene.
  10762. */
  10763. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10764. /**
  10765. * The component name helpfull to identify the component in the list of scene components.
  10766. */
  10767. readonly name: string;
  10768. /**
  10769. * The scene the component belongs to.
  10770. */
  10771. scene: Scene;
  10772. /**
  10773. * Creates a new instance of the component for the given scene
  10774. * @param scene Defines the scene to register the component in
  10775. */
  10776. constructor(scene: Scene);
  10777. /**
  10778. * Registers the component in a given scene
  10779. */
  10780. register(): void;
  10781. /**
  10782. * Rebuilds the elements related to this component in case of
  10783. * context lost for instance.
  10784. */
  10785. rebuild(): void;
  10786. /**
  10787. * Disposes the component and the associated ressources.
  10788. */
  10789. dispose(): void;
  10790. private _beforeClear;
  10791. }
  10792. }
  10793. declare module BABYLON {
  10794. interface ThinEngine {
  10795. /**
  10796. * Creates a new render target cube texture
  10797. * @param size defines the size of the texture
  10798. * @param options defines the options used to create the texture
  10799. * @returns a new render target cube texture stored in an InternalTexture
  10800. */
  10801. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. /** @hidden */
  10806. export var proceduralVertexShader: {
  10807. name: string;
  10808. shader: string;
  10809. };
  10810. }
  10811. declare module BABYLON {
  10812. /**
  10813. * 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.
  10814. * This is the base class of any Procedural texture and contains most of the shareable code.
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10816. */
  10817. export class ProceduralTexture extends Texture {
  10818. isCube: boolean;
  10819. /**
  10820. * Define if the texture is enabled or not (disabled texture will not render)
  10821. */
  10822. isEnabled: boolean;
  10823. /**
  10824. * Define if the texture must be cleared before rendering (default is true)
  10825. */
  10826. autoClear: boolean;
  10827. /**
  10828. * Callback called when the texture is generated
  10829. */
  10830. onGenerated: () => void;
  10831. /**
  10832. * Event raised when the texture is generated
  10833. */
  10834. onGeneratedObservable: Observable<ProceduralTexture>;
  10835. /** @hidden */
  10836. _generateMipMaps: boolean;
  10837. /** @hidden **/
  10838. _effect: Effect;
  10839. /** @hidden */
  10840. _textures: {
  10841. [key: string]: Texture;
  10842. };
  10843. /** @hidden */
  10844. protected _fallbackTexture: Nullable<Texture>;
  10845. private _size;
  10846. private _currentRefreshId;
  10847. private _frameId;
  10848. private _refreshRate;
  10849. private _vertexBuffers;
  10850. private _indexBuffer;
  10851. private _uniforms;
  10852. private _samplers;
  10853. private _fragment;
  10854. private _floats;
  10855. private _ints;
  10856. private _floatsArrays;
  10857. private _colors3;
  10858. private _colors4;
  10859. private _vectors2;
  10860. private _vectors3;
  10861. private _matrices;
  10862. private _fallbackTextureUsed;
  10863. private _engine;
  10864. private _cachedDefines;
  10865. private _contentUpdateId;
  10866. private _contentData;
  10867. /**
  10868. * Instantiates a new procedural texture.
  10869. * 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.
  10870. * This is the base class of any Procedural texture and contains most of the shareable code.
  10871. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10872. * @param name Define the name of the texture
  10873. * @param size Define the size of the texture to create
  10874. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10875. * @param scene Define the scene the texture belongs to
  10876. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10877. * @param generateMipMaps Define if the texture should creates mip maps or not
  10878. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10879. */
  10880. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10881. /**
  10882. * The effect that is created when initializing the post process.
  10883. * @returns The created effect corresponding the the postprocess.
  10884. */
  10885. getEffect(): Effect;
  10886. /**
  10887. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10888. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10889. */
  10890. getContent(): Nullable<ArrayBufferView>;
  10891. private _createIndexBuffer;
  10892. /** @hidden */
  10893. _rebuild(): void;
  10894. /**
  10895. * Resets the texture in order to recreate its associated resources.
  10896. * This can be called in case of context loss
  10897. */
  10898. reset(): void;
  10899. protected _getDefines(): string;
  10900. /**
  10901. * Is the texture ready to be used ? (rendered at least once)
  10902. * @returns true if ready, otherwise, false.
  10903. */
  10904. isReady(): boolean;
  10905. /**
  10906. * Resets the refresh counter of the texture and start bak from scratch.
  10907. * Could be useful to regenerate the texture if it is setup to render only once.
  10908. */
  10909. resetRefreshCounter(): void;
  10910. /**
  10911. * Set the fragment shader to use in order to render the texture.
  10912. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10913. */
  10914. setFragment(fragment: any): void;
  10915. /**
  10916. * Define the refresh rate of the texture or the rendering frequency.
  10917. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10918. */
  10919. get refreshRate(): number;
  10920. set refreshRate(value: number);
  10921. /** @hidden */
  10922. _shouldRender(): boolean;
  10923. /**
  10924. * Get the size the texture is rendering at.
  10925. * @returns the size (texture is always squared)
  10926. */
  10927. getRenderSize(): number;
  10928. /**
  10929. * Resize the texture to new value.
  10930. * @param size Define the new size the texture should have
  10931. * @param generateMipMaps Define whether the new texture should create mip maps
  10932. */
  10933. resize(size: number, generateMipMaps: boolean): void;
  10934. private _checkUniform;
  10935. /**
  10936. * Set a texture in the shader program used to render.
  10937. * @param name Define the name of the uniform samplers as defined in the shader
  10938. * @param texture Define the texture to bind to this sampler
  10939. * @return the texture itself allowing "fluent" like uniform updates
  10940. */
  10941. setTexture(name: string, texture: Texture): ProceduralTexture;
  10942. /**
  10943. * Set a float in the shader.
  10944. * @param name Define the name of the uniform as defined in the shader
  10945. * @param value Define the value to give to the uniform
  10946. * @return the texture itself allowing "fluent" like uniform updates
  10947. */
  10948. setFloat(name: string, value: number): ProceduralTexture;
  10949. /**
  10950. * Set a int in the shader.
  10951. * @param name Define the name of the uniform as defined in the shader
  10952. * @param value Define the value to give to the uniform
  10953. * @return the texture itself allowing "fluent" like uniform updates
  10954. */
  10955. setInt(name: string, value: number): ProceduralTexture;
  10956. /**
  10957. * Set an array of floats in the shader.
  10958. * @param name Define the name of the uniform as defined in the shader
  10959. * @param value Define the value to give to the uniform
  10960. * @return the texture itself allowing "fluent" like uniform updates
  10961. */
  10962. setFloats(name: string, value: number[]): ProceduralTexture;
  10963. /**
  10964. * Set a vec3 in the shader from a Color3.
  10965. * @param name Define the name of the uniform as defined in the shader
  10966. * @param value Define the value to give to the uniform
  10967. * @return the texture itself allowing "fluent" like uniform updates
  10968. */
  10969. setColor3(name: string, value: Color3): ProceduralTexture;
  10970. /**
  10971. * Set a vec4 in the shader from a Color4.
  10972. * @param name Define the name of the uniform as defined in the shader
  10973. * @param value Define the value to give to the uniform
  10974. * @return the texture itself allowing "fluent" like uniform updates
  10975. */
  10976. setColor4(name: string, value: Color4): ProceduralTexture;
  10977. /**
  10978. * Set a vec2 in the shader from a Vector2.
  10979. * @param name Define the name of the uniform as defined in the shader
  10980. * @param value Define the value to give to the uniform
  10981. * @return the texture itself allowing "fluent" like uniform updates
  10982. */
  10983. setVector2(name: string, value: Vector2): ProceduralTexture;
  10984. /**
  10985. * Set a vec3 in the shader from a Vector3.
  10986. * @param name Define the name of the uniform as defined in the shader
  10987. * @param value Define the value to give to the uniform
  10988. * @return the texture itself allowing "fluent" like uniform updates
  10989. */
  10990. setVector3(name: string, value: Vector3): ProceduralTexture;
  10991. /**
  10992. * Set a mat4 in the shader from a MAtrix.
  10993. * @param name Define the name of the uniform as defined in the shader
  10994. * @param value Define the value to give to the uniform
  10995. * @return the texture itself allowing "fluent" like uniform updates
  10996. */
  10997. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10998. /**
  10999. * Render the texture to its associated render target.
  11000. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11001. */
  11002. render(useCameraPostProcess?: boolean): void;
  11003. /**
  11004. * Clone the texture.
  11005. * @returns the cloned texture
  11006. */
  11007. clone(): ProceduralTexture;
  11008. /**
  11009. * Dispose the texture and release its asoociated resources.
  11010. */
  11011. dispose(): void;
  11012. }
  11013. }
  11014. declare module BABYLON {
  11015. /**
  11016. * This represents the base class for particle system in Babylon.
  11017. * 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.
  11018. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11019. * @example https://doc.babylonjs.com/babylon101/particles
  11020. */
  11021. export class BaseParticleSystem {
  11022. /**
  11023. * Source color is added to the destination color without alpha affecting the result
  11024. */
  11025. static BLENDMODE_ONEONE: number;
  11026. /**
  11027. * Blend current color and particle color using particle’s alpha
  11028. */
  11029. static BLENDMODE_STANDARD: number;
  11030. /**
  11031. * Add current color and particle color multiplied by particle’s alpha
  11032. */
  11033. static BLENDMODE_ADD: number;
  11034. /**
  11035. * Multiply current color with particle color
  11036. */
  11037. static BLENDMODE_MULTIPLY: number;
  11038. /**
  11039. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11040. */
  11041. static BLENDMODE_MULTIPLYADD: number;
  11042. /**
  11043. * List of animations used by the particle system.
  11044. */
  11045. animations: Animation[];
  11046. /**
  11047. * Gets or sets the unique id of the particle system
  11048. */
  11049. uniqueId: number;
  11050. /**
  11051. * The id of the Particle system.
  11052. */
  11053. id: string;
  11054. /**
  11055. * The friendly name of the Particle system.
  11056. */
  11057. name: string;
  11058. /**
  11059. * Snippet ID if the particle system was created from the snippet server
  11060. */
  11061. snippetId: string;
  11062. /**
  11063. * The rendering group used by the Particle system to chose when to render.
  11064. */
  11065. renderingGroupId: number;
  11066. /**
  11067. * The emitter represents the Mesh or position we are attaching the particle system to.
  11068. */
  11069. emitter: Nullable<AbstractMesh | Vector3>;
  11070. /**
  11071. * The maximum number of particles to emit per frame
  11072. */
  11073. emitRate: number;
  11074. /**
  11075. * If you want to launch only a few particles at once, that can be done, as well.
  11076. */
  11077. manualEmitCount: number;
  11078. /**
  11079. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11080. */
  11081. updateSpeed: number;
  11082. /**
  11083. * The amount of time the particle system is running (depends of the overall update speed).
  11084. */
  11085. targetStopDuration: number;
  11086. /**
  11087. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11088. */
  11089. disposeOnStop: boolean;
  11090. /**
  11091. * Minimum power of emitting particles.
  11092. */
  11093. minEmitPower: number;
  11094. /**
  11095. * Maximum power of emitting particles.
  11096. */
  11097. maxEmitPower: number;
  11098. /**
  11099. * Minimum life time of emitting particles.
  11100. */
  11101. minLifeTime: number;
  11102. /**
  11103. * Maximum life time of emitting particles.
  11104. */
  11105. maxLifeTime: number;
  11106. /**
  11107. * Minimum Size of emitting particles.
  11108. */
  11109. minSize: number;
  11110. /**
  11111. * Maximum Size of emitting particles.
  11112. */
  11113. maxSize: number;
  11114. /**
  11115. * Minimum scale of emitting particles on X axis.
  11116. */
  11117. minScaleX: number;
  11118. /**
  11119. * Maximum scale of emitting particles on X axis.
  11120. */
  11121. maxScaleX: number;
  11122. /**
  11123. * Minimum scale of emitting particles on Y axis.
  11124. */
  11125. minScaleY: number;
  11126. /**
  11127. * Maximum scale of emitting particles on Y axis.
  11128. */
  11129. maxScaleY: number;
  11130. /**
  11131. * Gets or sets the minimal initial rotation in radians.
  11132. */
  11133. minInitialRotation: number;
  11134. /**
  11135. * Gets or sets the maximal initial rotation in radians.
  11136. */
  11137. maxInitialRotation: number;
  11138. /**
  11139. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11140. */
  11141. minAngularSpeed: number;
  11142. /**
  11143. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11144. */
  11145. maxAngularSpeed: number;
  11146. /**
  11147. * The texture used to render each particle. (this can be a spritesheet)
  11148. */
  11149. particleTexture: Nullable<Texture>;
  11150. /**
  11151. * The layer mask we are rendering the particles through.
  11152. */
  11153. layerMask: number;
  11154. /**
  11155. * This can help using your own shader to render the particle system.
  11156. * The according effect will be created
  11157. */
  11158. customShader: any;
  11159. /**
  11160. * By default particle system starts as soon as they are created. This prevents the
  11161. * automatic start to happen and let you decide when to start emitting particles.
  11162. */
  11163. preventAutoStart: boolean;
  11164. private _noiseTexture;
  11165. /**
  11166. * Gets or sets a texture used to add random noise to particle positions
  11167. */
  11168. get noiseTexture(): Nullable<ProceduralTexture>;
  11169. set noiseTexture(value: Nullable<ProceduralTexture>);
  11170. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11171. noiseStrength: Vector3;
  11172. /**
  11173. * Callback triggered when the particle animation is ending.
  11174. */
  11175. onAnimationEnd: Nullable<() => void>;
  11176. /**
  11177. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11178. */
  11179. blendMode: number;
  11180. /**
  11181. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11182. * to override the particles.
  11183. */
  11184. forceDepthWrite: boolean;
  11185. /** 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 */
  11186. preWarmCycles: number;
  11187. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11188. preWarmStepOffset: number;
  11189. /**
  11190. * 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)
  11191. */
  11192. spriteCellChangeSpeed: number;
  11193. /**
  11194. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11195. */
  11196. startSpriteCellID: number;
  11197. /**
  11198. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11199. */
  11200. endSpriteCellID: number;
  11201. /**
  11202. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11203. */
  11204. spriteCellWidth: number;
  11205. /**
  11206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11207. */
  11208. spriteCellHeight: number;
  11209. /**
  11210. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11211. */
  11212. spriteRandomStartCell: boolean;
  11213. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11214. translationPivot: Vector2;
  11215. /** @hidden */
  11216. protected _isAnimationSheetEnabled: boolean;
  11217. /**
  11218. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11219. */
  11220. beginAnimationOnStart: boolean;
  11221. /**
  11222. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11223. */
  11224. beginAnimationFrom: number;
  11225. /**
  11226. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11227. */
  11228. beginAnimationTo: number;
  11229. /**
  11230. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11231. */
  11232. beginAnimationLoop: boolean;
  11233. /**
  11234. * Gets or sets a world offset applied to all particles
  11235. */
  11236. worldOffset: Vector3;
  11237. /**
  11238. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11239. */
  11240. get isAnimationSheetEnabled(): boolean;
  11241. set isAnimationSheetEnabled(value: boolean);
  11242. /**
  11243. * Get hosting scene
  11244. * @returns the scene
  11245. */
  11246. getScene(): Scene;
  11247. /**
  11248. * You can use gravity if you want to give an orientation to your particles.
  11249. */
  11250. gravity: Vector3;
  11251. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11252. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11253. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11254. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11255. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11256. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11257. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11258. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11259. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11260. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11261. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11262. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11263. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11264. /**
  11265. * Defines the delay in milliseconds before starting the system (0 by default)
  11266. */
  11267. startDelay: number;
  11268. /**
  11269. * Gets the current list of drag gradients.
  11270. * You must use addDragGradient and removeDragGradient to udpate this list
  11271. * @returns the list of drag gradients
  11272. */
  11273. getDragGradients(): Nullable<Array<FactorGradient>>;
  11274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11275. limitVelocityDamping: number;
  11276. /**
  11277. * Gets the current list of limit velocity gradients.
  11278. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11279. * @returns the list of limit velocity gradients
  11280. */
  11281. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11282. /**
  11283. * Gets the current list of color gradients.
  11284. * You must use addColorGradient and removeColorGradient to udpate this list
  11285. * @returns the list of color gradients
  11286. */
  11287. getColorGradients(): Nullable<Array<ColorGradient>>;
  11288. /**
  11289. * Gets the current list of size gradients.
  11290. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11291. * @returns the list of size gradients
  11292. */
  11293. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11294. /**
  11295. * Gets the current list of color remap gradients.
  11296. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11297. * @returns the list of color remap gradients
  11298. */
  11299. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11300. /**
  11301. * Gets the current list of alpha remap gradients.
  11302. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11303. * @returns the list of alpha remap gradients
  11304. */
  11305. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11306. /**
  11307. * Gets the current list of life time gradients.
  11308. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11309. * @returns the list of life time gradients
  11310. */
  11311. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11312. /**
  11313. * Gets the current list of angular speed gradients.
  11314. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11315. * @returns the list of angular speed gradients
  11316. */
  11317. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11318. /**
  11319. * Gets the current list of velocity gradients.
  11320. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11321. * @returns the list of velocity gradients
  11322. */
  11323. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11324. /**
  11325. * Gets the current list of start size gradients.
  11326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11327. * @returns the list of start size gradients
  11328. */
  11329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11330. /**
  11331. * Gets the current list of emit rate gradients.
  11332. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11333. * @returns the list of emit rate gradients
  11334. */
  11335. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11336. /**
  11337. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11338. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11339. */
  11340. get direction1(): Vector3;
  11341. set direction1(value: Vector3);
  11342. /**
  11343. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11344. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11345. */
  11346. get direction2(): Vector3;
  11347. set direction2(value: Vector3);
  11348. /**
  11349. * 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.
  11350. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11351. */
  11352. get minEmitBox(): Vector3;
  11353. set minEmitBox(value: Vector3);
  11354. /**
  11355. * 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.
  11356. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11357. */
  11358. get maxEmitBox(): Vector3;
  11359. set maxEmitBox(value: Vector3);
  11360. /**
  11361. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11362. */
  11363. color1: Color4;
  11364. /**
  11365. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11366. */
  11367. color2: Color4;
  11368. /**
  11369. * Color the particle will have at the end of its lifetime
  11370. */
  11371. colorDead: Color4;
  11372. /**
  11373. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11374. */
  11375. textureMask: Color4;
  11376. /**
  11377. * The particle emitter type defines the emitter used by the particle system.
  11378. * It can be for example box, sphere, or cone...
  11379. */
  11380. particleEmitterType: IParticleEmitterType;
  11381. /** @hidden */
  11382. _isSubEmitter: boolean;
  11383. /**
  11384. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11385. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11386. */
  11387. billboardMode: number;
  11388. protected _isBillboardBased: boolean;
  11389. /**
  11390. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11391. */
  11392. get isBillboardBased(): boolean;
  11393. set isBillboardBased(value: boolean);
  11394. /**
  11395. * The scene the particle system belongs to.
  11396. */
  11397. protected _scene: Scene;
  11398. /**
  11399. * Local cache of defines for image processing.
  11400. */
  11401. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11402. /**
  11403. * Default configuration related to image processing available in the standard Material.
  11404. */
  11405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11406. /**
  11407. * Gets the image processing configuration used either in this material.
  11408. */
  11409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11410. /**
  11411. * Sets the Default image processing configuration used either in the this material.
  11412. *
  11413. * If sets to null, the scene one is in use.
  11414. */
  11415. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11416. /**
  11417. * Attaches a new image processing configuration to the Standard Material.
  11418. * @param configuration
  11419. */
  11420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11421. /** @hidden */
  11422. protected _reset(): void;
  11423. /** @hidden */
  11424. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11425. /**
  11426. * Instantiates a particle system.
  11427. * 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.
  11428. * @param name The name of the particle system
  11429. */
  11430. constructor(name: string);
  11431. /**
  11432. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11433. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11434. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11435. * @returns the emitter
  11436. */
  11437. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11438. /**
  11439. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11440. * @param radius The radius of the hemisphere to emit from
  11441. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11442. * @returns the emitter
  11443. */
  11444. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11445. /**
  11446. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11447. * @param radius The radius of the sphere to emit from
  11448. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11449. * @returns the emitter
  11450. */
  11451. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11452. /**
  11453. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11454. * @param radius The radius of the sphere to emit from
  11455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11457. * @returns the emitter
  11458. */
  11459. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11460. /**
  11461. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11462. * @param radius The radius of the emission cylinder
  11463. * @param height The height of the emission cylinder
  11464. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11465. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11466. * @returns the emitter
  11467. */
  11468. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11469. /**
  11470. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11471. * @param radius The radius of the cylinder to emit from
  11472. * @param height The height of the emission cylinder
  11473. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11476. * @returns the emitter
  11477. */
  11478. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11479. /**
  11480. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11481. * @param radius The radius of the cone to emit from
  11482. * @param angle The base angle of the cone
  11483. * @returns the emitter
  11484. */
  11485. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11486. /**
  11487. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11490. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11491. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11492. * @returns the emitter
  11493. */
  11494. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11495. }
  11496. }
  11497. declare module BABYLON {
  11498. /**
  11499. * Type of sub emitter
  11500. */
  11501. export enum SubEmitterType {
  11502. /**
  11503. * Attached to the particle over it's lifetime
  11504. */
  11505. ATTACHED = 0,
  11506. /**
  11507. * Created when the particle dies
  11508. */
  11509. END = 1
  11510. }
  11511. /**
  11512. * Sub emitter class used to emit particles from an existing particle
  11513. */
  11514. export class SubEmitter {
  11515. /**
  11516. * the particle system to be used by the sub emitter
  11517. */
  11518. particleSystem: ParticleSystem;
  11519. /**
  11520. * Type of the submitter (Default: END)
  11521. */
  11522. type: SubEmitterType;
  11523. /**
  11524. * 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)
  11525. * Note: This only is supported when using an emitter of type Mesh
  11526. */
  11527. inheritDirection: boolean;
  11528. /**
  11529. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11530. */
  11531. inheritedVelocityAmount: number;
  11532. /**
  11533. * Creates a sub emitter
  11534. * @param particleSystem the particle system to be used by the sub emitter
  11535. */
  11536. constructor(
  11537. /**
  11538. * the particle system to be used by the sub emitter
  11539. */
  11540. particleSystem: ParticleSystem);
  11541. /**
  11542. * Clones the sub emitter
  11543. * @returns the cloned sub emitter
  11544. */
  11545. clone(): SubEmitter;
  11546. /**
  11547. * Serialize current object to a JSON object
  11548. * @returns the serialized object
  11549. */
  11550. serialize(): any;
  11551. /** @hidden */
  11552. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11553. /**
  11554. * Creates a new SubEmitter from a serialized JSON version
  11555. * @param serializationObject defines the JSON object to read from
  11556. * @param scene defines the hosting scene
  11557. * @param rootUrl defines the rootUrl for data loading
  11558. * @returns a new SubEmitter
  11559. */
  11560. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11561. /** Release associated resources */
  11562. dispose(): void;
  11563. }
  11564. }
  11565. declare module BABYLON {
  11566. /** @hidden */
  11567. export var imageProcessingDeclaration: {
  11568. name: string;
  11569. shader: string;
  11570. };
  11571. }
  11572. declare module BABYLON {
  11573. /** @hidden */
  11574. export var imageProcessingFunctions: {
  11575. name: string;
  11576. shader: string;
  11577. };
  11578. }
  11579. declare module BABYLON {
  11580. /** @hidden */
  11581. export var particlesPixelShader: {
  11582. name: string;
  11583. shader: string;
  11584. };
  11585. }
  11586. declare module BABYLON {
  11587. /** @hidden */
  11588. export var particlesVertexShader: {
  11589. name: string;
  11590. shader: string;
  11591. };
  11592. }
  11593. declare module BABYLON {
  11594. /**
  11595. * This represents a particle system in Babylon.
  11596. * 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.
  11597. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11598. * @example https://doc.babylonjs.com/babylon101/particles
  11599. */
  11600. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11601. /**
  11602. * Billboard mode will only apply to Y axis
  11603. */
  11604. static readonly BILLBOARDMODE_Y: number;
  11605. /**
  11606. * Billboard mode will apply to all axes
  11607. */
  11608. static readonly BILLBOARDMODE_ALL: number;
  11609. /**
  11610. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11611. */
  11612. static readonly BILLBOARDMODE_STRETCHED: number;
  11613. /**
  11614. * This function can be defined to provide custom update for active particles.
  11615. * This function will be called instead of regular update (age, position, color, etc.).
  11616. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11617. */
  11618. updateFunction: (particles: Particle[]) => void;
  11619. private _emitterWorldMatrix;
  11620. /**
  11621. * This function can be defined to specify initial direction for every new particle.
  11622. * It by default use the emitterType defined function
  11623. */
  11624. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11625. /**
  11626. * This function can be defined to specify initial position for every new particle.
  11627. * It by default use the emitterType defined function
  11628. */
  11629. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11630. /**
  11631. * @hidden
  11632. */
  11633. _inheritedVelocityOffset: Vector3;
  11634. /**
  11635. * An event triggered when the system is disposed
  11636. */
  11637. onDisposeObservable: Observable<ParticleSystem>;
  11638. private _onDisposeObserver;
  11639. /**
  11640. * Sets a callback that will be triggered when the system is disposed
  11641. */
  11642. set onDispose(callback: () => void);
  11643. private _particles;
  11644. private _epsilon;
  11645. private _capacity;
  11646. private _stockParticles;
  11647. private _newPartsExcess;
  11648. private _vertexData;
  11649. private _vertexBuffer;
  11650. private _vertexBuffers;
  11651. private _spriteBuffer;
  11652. private _indexBuffer;
  11653. private _effect;
  11654. private _customEffect;
  11655. private _cachedDefines;
  11656. private _scaledColorStep;
  11657. private _colorDiff;
  11658. private _scaledDirection;
  11659. private _scaledGravity;
  11660. private _currentRenderId;
  11661. private _alive;
  11662. private _useInstancing;
  11663. private _started;
  11664. private _stopped;
  11665. private _actualFrame;
  11666. private _scaledUpdateSpeed;
  11667. private _vertexBufferSize;
  11668. /** @hidden */
  11669. _currentEmitRateGradient: Nullable<FactorGradient>;
  11670. /** @hidden */
  11671. _currentEmitRate1: number;
  11672. /** @hidden */
  11673. _currentEmitRate2: number;
  11674. /** @hidden */
  11675. _currentStartSizeGradient: Nullable<FactorGradient>;
  11676. /** @hidden */
  11677. _currentStartSize1: number;
  11678. /** @hidden */
  11679. _currentStartSize2: number;
  11680. private readonly _rawTextureWidth;
  11681. private _rampGradientsTexture;
  11682. private _useRampGradients;
  11683. /** Gets or sets a boolean indicating that ramp gradients must be used
  11684. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11685. */
  11686. get useRampGradients(): boolean;
  11687. set useRampGradients(value: boolean);
  11688. /**
  11689. * 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.
  11690. * 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: [])
  11691. */
  11692. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11693. private _subEmitters;
  11694. /**
  11695. * @hidden
  11696. * If the particle systems emitter should be disposed when the particle system is disposed
  11697. */
  11698. _disposeEmitterOnDispose: boolean;
  11699. /**
  11700. * The current active Sub-systems, this property is used by the root particle system only.
  11701. */
  11702. activeSubSystems: Array<ParticleSystem>;
  11703. /**
  11704. * Specifies if the particles are updated in emitter local space or world space
  11705. */
  11706. isLocal: boolean;
  11707. private _rootParticleSystem;
  11708. /**
  11709. * Gets the current list of active particles
  11710. */
  11711. get particles(): Particle[];
  11712. /**
  11713. * Gets the number of particles active at the same time.
  11714. * @returns The number of active particles.
  11715. */
  11716. getActiveCount(): number;
  11717. /**
  11718. * Returns the string "ParticleSystem"
  11719. * @returns a string containing the class name
  11720. */
  11721. getClassName(): string;
  11722. /**
  11723. * Gets a boolean indicating that the system is stopping
  11724. * @returns true if the system is currently stopping
  11725. */
  11726. isStopping(): boolean;
  11727. /**
  11728. * Instantiates a particle system.
  11729. * 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.
  11730. * @param name The name of the particle system
  11731. * @param capacity The max number of particles alive at the same time
  11732. * @param scene The scene the particle system belongs to
  11733. * @param customEffect a custom effect used to change the way particles are rendered by default
  11734. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11735. * @param epsilon Offset used to render the particles
  11736. */
  11737. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11738. private _addFactorGradient;
  11739. private _removeFactorGradient;
  11740. /**
  11741. * Adds a new life time gradient
  11742. * @param gradient defines the gradient to use (between 0 and 1)
  11743. * @param factor defines the life time factor to affect to the specified gradient
  11744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11745. * @returns the current particle system
  11746. */
  11747. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11748. /**
  11749. * Remove a specific life time gradient
  11750. * @param gradient defines the gradient to remove
  11751. * @returns the current particle system
  11752. */
  11753. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11754. /**
  11755. * Adds a new size gradient
  11756. * @param gradient defines the gradient to use (between 0 and 1)
  11757. * @param factor defines the size factor to affect to the specified gradient
  11758. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11759. * @returns the current particle system
  11760. */
  11761. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11762. /**
  11763. * Remove a specific size gradient
  11764. * @param gradient defines the gradient to remove
  11765. * @returns the current particle system
  11766. */
  11767. removeSizeGradient(gradient: number): IParticleSystem;
  11768. /**
  11769. * Adds a new color remap gradient
  11770. * @param gradient defines the gradient to use (between 0 and 1)
  11771. * @param min defines the color remap minimal range
  11772. * @param max defines the color remap maximal range
  11773. * @returns the current particle system
  11774. */
  11775. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11776. /**
  11777. * Remove a specific color remap gradient
  11778. * @param gradient defines the gradient to remove
  11779. * @returns the current particle system
  11780. */
  11781. removeColorRemapGradient(gradient: number): IParticleSystem;
  11782. /**
  11783. * Adds a new alpha remap gradient
  11784. * @param gradient defines the gradient to use (between 0 and 1)
  11785. * @param min defines the alpha remap minimal range
  11786. * @param max defines the alpha remap maximal range
  11787. * @returns the current particle system
  11788. */
  11789. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11790. /**
  11791. * Remove a specific alpha remap gradient
  11792. * @param gradient defines the gradient to remove
  11793. * @returns the current particle system
  11794. */
  11795. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11796. /**
  11797. * Adds a new angular speed gradient
  11798. * @param gradient defines the gradient to use (between 0 and 1)
  11799. * @param factor defines the angular speed to affect to the specified gradient
  11800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11801. * @returns the current particle system
  11802. */
  11803. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11804. /**
  11805. * Remove a specific angular speed gradient
  11806. * @param gradient defines the gradient to remove
  11807. * @returns the current particle system
  11808. */
  11809. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11810. /**
  11811. * Adds a new velocity gradient
  11812. * @param gradient defines the gradient to use (between 0 and 1)
  11813. * @param factor defines the velocity to affect to the specified gradient
  11814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11815. * @returns the current particle system
  11816. */
  11817. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11818. /**
  11819. * Remove a specific velocity gradient
  11820. * @param gradient defines the gradient to remove
  11821. * @returns the current particle system
  11822. */
  11823. removeVelocityGradient(gradient: number): IParticleSystem;
  11824. /**
  11825. * Adds a new limit velocity gradient
  11826. * @param gradient defines the gradient to use (between 0 and 1)
  11827. * @param factor defines the limit velocity value to affect to the specified gradient
  11828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11829. * @returns the current particle system
  11830. */
  11831. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11832. /**
  11833. * Remove a specific limit velocity gradient
  11834. * @param gradient defines the gradient to remove
  11835. * @returns the current particle system
  11836. */
  11837. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11838. /**
  11839. * Adds a new drag gradient
  11840. * @param gradient defines the gradient to use (between 0 and 1)
  11841. * @param factor defines the drag value to affect to the specified gradient
  11842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11843. * @returns the current particle system
  11844. */
  11845. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11846. /**
  11847. * Remove a specific drag gradient
  11848. * @param gradient defines the gradient to remove
  11849. * @returns the current particle system
  11850. */
  11851. removeDragGradient(gradient: number): IParticleSystem;
  11852. /**
  11853. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11854. * @param gradient defines the gradient to use (between 0 and 1)
  11855. * @param factor defines the emit rate value to affect to the specified gradient
  11856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11857. * @returns the current particle system
  11858. */
  11859. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11860. /**
  11861. * Remove a specific emit rate gradient
  11862. * @param gradient defines the gradient to remove
  11863. * @returns the current particle system
  11864. */
  11865. removeEmitRateGradient(gradient: number): IParticleSystem;
  11866. /**
  11867. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11868. * @param gradient defines the gradient to use (between 0 and 1)
  11869. * @param factor defines the start size value to affect to the specified gradient
  11870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11871. * @returns the current particle system
  11872. */
  11873. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11874. /**
  11875. * Remove a specific start size gradient
  11876. * @param gradient defines the gradient to remove
  11877. * @returns the current particle system
  11878. */
  11879. removeStartSizeGradient(gradient: number): IParticleSystem;
  11880. private _createRampGradientTexture;
  11881. /**
  11882. * Gets the current list of ramp gradients.
  11883. * You must use addRampGradient and removeRampGradient to udpate this list
  11884. * @returns the list of ramp gradients
  11885. */
  11886. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11887. /**
  11888. * Adds a new ramp gradient used to remap particle colors
  11889. * @param gradient defines the gradient to use (between 0 and 1)
  11890. * @param color defines the color to affect to the specified gradient
  11891. * @returns the current particle system
  11892. */
  11893. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11894. /**
  11895. * Remove a specific ramp gradient
  11896. * @param gradient defines the gradient to remove
  11897. * @returns the current particle system
  11898. */
  11899. removeRampGradient(gradient: number): ParticleSystem;
  11900. /**
  11901. * Adds a new color gradient
  11902. * @param gradient defines the gradient to use (between 0 and 1)
  11903. * @param color1 defines the color to affect to the specified gradient
  11904. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11905. * @returns this particle system
  11906. */
  11907. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11908. /**
  11909. * Remove a specific color gradient
  11910. * @param gradient defines the gradient to remove
  11911. * @returns this particle system
  11912. */
  11913. removeColorGradient(gradient: number): IParticleSystem;
  11914. private _fetchR;
  11915. protected _reset(): void;
  11916. private _resetEffect;
  11917. private _createVertexBuffers;
  11918. private _createIndexBuffer;
  11919. /**
  11920. * Gets the maximum number of particles active at the same time.
  11921. * @returns The max number of active particles.
  11922. */
  11923. getCapacity(): number;
  11924. /**
  11925. * Gets whether there are still active particles in the system.
  11926. * @returns True if it is alive, otherwise false.
  11927. */
  11928. isAlive(): boolean;
  11929. /**
  11930. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11931. * @returns True if it has been started, otherwise false.
  11932. */
  11933. isStarted(): boolean;
  11934. private _prepareSubEmitterInternalArray;
  11935. /**
  11936. * Starts the particle system and begins to emit
  11937. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11938. */
  11939. start(delay?: number): void;
  11940. /**
  11941. * Stops the particle system.
  11942. * @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.
  11943. */
  11944. stop(stopSubEmitters?: boolean): void;
  11945. /**
  11946. * Remove all active particles
  11947. */
  11948. reset(): void;
  11949. /**
  11950. * @hidden (for internal use only)
  11951. */
  11952. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11953. /**
  11954. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11955. * Its lifetime will start back at 0.
  11956. */
  11957. recycleParticle: (particle: Particle) => void;
  11958. private _stopSubEmitters;
  11959. private _createParticle;
  11960. private _removeFromRoot;
  11961. private _emitFromParticle;
  11962. private _update;
  11963. /** @hidden */
  11964. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11965. /** @hidden */
  11966. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11967. /** @hidden */
  11968. private _getEffect;
  11969. /**
  11970. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11971. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11972. */
  11973. animate(preWarmOnly?: boolean): void;
  11974. private _appendParticleVertices;
  11975. /**
  11976. * Rebuilds the particle system.
  11977. */
  11978. rebuild(): void;
  11979. /**
  11980. * Is this system ready to be used/rendered
  11981. * @return true if the system is ready
  11982. */
  11983. isReady(): boolean;
  11984. private _render;
  11985. /**
  11986. * Renders the particle system in its current state.
  11987. * @returns the current number of particles
  11988. */
  11989. render(): number;
  11990. /**
  11991. * Disposes the particle system and free the associated resources
  11992. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11993. */
  11994. dispose(disposeTexture?: boolean): void;
  11995. /**
  11996. * Clones the particle system.
  11997. * @param name The name of the cloned object
  11998. * @param newEmitter The new emitter to use
  11999. * @returns the cloned particle system
  12000. */
  12001. clone(name: string, newEmitter: any): ParticleSystem;
  12002. /**
  12003. * Serializes the particle system to a JSON object.
  12004. * @returns the JSON object
  12005. */
  12006. serialize(): any;
  12007. /** @hidden */
  12008. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12009. /** @hidden */
  12010. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12011. /**
  12012. * Parses a JSON object to create a particle system.
  12013. * @param parsedParticleSystem The JSON object to parse
  12014. * @param scene The scene to create the particle system in
  12015. * @param rootUrl The root url to use to load external dependencies like texture
  12016. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12017. * @returns the Parsed particle system
  12018. */
  12019. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12020. }
  12021. }
  12022. declare module BABYLON {
  12023. /**
  12024. * A particle represents one of the element emitted by a particle system.
  12025. * This is mainly define by its coordinates, direction, velocity and age.
  12026. */
  12027. export class Particle {
  12028. /**
  12029. * The particle system the particle belongs to.
  12030. */
  12031. particleSystem: ParticleSystem;
  12032. private static _Count;
  12033. /**
  12034. * Unique ID of the particle
  12035. */
  12036. id: number;
  12037. /**
  12038. * The world position of the particle in the scene.
  12039. */
  12040. position: Vector3;
  12041. /**
  12042. * The world direction of the particle in the scene.
  12043. */
  12044. direction: Vector3;
  12045. /**
  12046. * The color of the particle.
  12047. */
  12048. color: Color4;
  12049. /**
  12050. * The color change of the particle per step.
  12051. */
  12052. colorStep: Color4;
  12053. /**
  12054. * Defines how long will the life of the particle be.
  12055. */
  12056. lifeTime: number;
  12057. /**
  12058. * The current age of the particle.
  12059. */
  12060. age: number;
  12061. /**
  12062. * The current size of the particle.
  12063. */
  12064. size: number;
  12065. /**
  12066. * The current scale of the particle.
  12067. */
  12068. scale: Vector2;
  12069. /**
  12070. * The current angle of the particle.
  12071. */
  12072. angle: number;
  12073. /**
  12074. * Defines how fast is the angle changing.
  12075. */
  12076. angularSpeed: number;
  12077. /**
  12078. * Defines the cell index used by the particle to be rendered from a sprite.
  12079. */
  12080. cellIndex: number;
  12081. /**
  12082. * The information required to support color remapping
  12083. */
  12084. remapData: Vector4;
  12085. /** @hidden */
  12086. _randomCellOffset?: number;
  12087. /** @hidden */
  12088. _initialDirection: Nullable<Vector3>;
  12089. /** @hidden */
  12090. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12091. /** @hidden */
  12092. _initialStartSpriteCellID: number;
  12093. /** @hidden */
  12094. _initialEndSpriteCellID: number;
  12095. /** @hidden */
  12096. _currentColorGradient: Nullable<ColorGradient>;
  12097. /** @hidden */
  12098. _currentColor1: Color4;
  12099. /** @hidden */
  12100. _currentColor2: Color4;
  12101. /** @hidden */
  12102. _currentSizeGradient: Nullable<FactorGradient>;
  12103. /** @hidden */
  12104. _currentSize1: number;
  12105. /** @hidden */
  12106. _currentSize2: number;
  12107. /** @hidden */
  12108. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12109. /** @hidden */
  12110. _currentAngularSpeed1: number;
  12111. /** @hidden */
  12112. _currentAngularSpeed2: number;
  12113. /** @hidden */
  12114. _currentVelocityGradient: Nullable<FactorGradient>;
  12115. /** @hidden */
  12116. _currentVelocity1: number;
  12117. /** @hidden */
  12118. _currentVelocity2: number;
  12119. /** @hidden */
  12120. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12121. /** @hidden */
  12122. _currentLimitVelocity1: number;
  12123. /** @hidden */
  12124. _currentLimitVelocity2: number;
  12125. /** @hidden */
  12126. _currentDragGradient: Nullable<FactorGradient>;
  12127. /** @hidden */
  12128. _currentDrag1: number;
  12129. /** @hidden */
  12130. _currentDrag2: number;
  12131. /** @hidden */
  12132. _randomNoiseCoordinates1: Vector3;
  12133. /** @hidden */
  12134. _randomNoiseCoordinates2: Vector3;
  12135. /** @hidden */
  12136. _localPosition?: Vector3;
  12137. /**
  12138. * Creates a new instance Particle
  12139. * @param particleSystem the particle system the particle belongs to
  12140. */
  12141. constructor(
  12142. /**
  12143. * The particle system the particle belongs to.
  12144. */
  12145. particleSystem: ParticleSystem);
  12146. private updateCellInfoFromSystem;
  12147. /**
  12148. * Defines how the sprite cell index is updated for the particle
  12149. */
  12150. updateCellIndex(): void;
  12151. /** @hidden */
  12152. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12153. /** @hidden */
  12154. _inheritParticleInfoToSubEmitters(): void;
  12155. /** @hidden */
  12156. _reset(): void;
  12157. /**
  12158. * Copy the properties of particle to another one.
  12159. * @param other the particle to copy the information to.
  12160. */
  12161. copyTo(other: Particle): void;
  12162. }
  12163. }
  12164. declare module BABYLON {
  12165. /**
  12166. * Particle emitter represents a volume emitting particles.
  12167. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12168. */
  12169. export interface IParticleEmitterType {
  12170. /**
  12171. * Called by the particle System when the direction is computed for the created particle.
  12172. * @param worldMatrix is the world matrix of the particle system
  12173. * @param directionToUpdate is the direction vector to update with the result
  12174. * @param particle is the particle we are computed the direction for
  12175. * @param isLocal defines if the direction should be set in local space
  12176. */
  12177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12178. /**
  12179. * Called by the particle System when the position is computed for the created particle.
  12180. * @param worldMatrix is the world matrix of the particle system
  12181. * @param positionToUpdate is the position vector to update with the result
  12182. * @param particle is the particle we are computed the position for
  12183. * @param isLocal defines if the position should be set in local space
  12184. */
  12185. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12186. /**
  12187. * Clones the current emitter and returns a copy of it
  12188. * @returns the new emitter
  12189. */
  12190. clone(): IParticleEmitterType;
  12191. /**
  12192. * Called by the GPUParticleSystem to setup the update shader
  12193. * @param effect defines the update shader
  12194. */
  12195. applyToShader(effect: Effect): void;
  12196. /**
  12197. * Returns a string to use to update the GPU particles update shader
  12198. * @returns the effect defines string
  12199. */
  12200. getEffectDefines(): string;
  12201. /**
  12202. * Returns a string representing the class name
  12203. * @returns a string containing the class name
  12204. */
  12205. getClassName(): string;
  12206. /**
  12207. * Serializes the particle system to a JSON object.
  12208. * @returns the JSON object
  12209. */
  12210. serialize(): any;
  12211. /**
  12212. * Parse properties from a JSON object
  12213. * @param serializationObject defines the JSON object
  12214. * @param scene defines the hosting scene
  12215. */
  12216. parse(serializationObject: any, scene: Scene): void;
  12217. }
  12218. }
  12219. declare module BABYLON {
  12220. /**
  12221. * Particle emitter emitting particles from the inside of a box.
  12222. * It emits the particles randomly between 2 given directions.
  12223. */
  12224. export class BoxParticleEmitter implements IParticleEmitterType {
  12225. /**
  12226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12227. */
  12228. direction1: Vector3;
  12229. /**
  12230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12231. */
  12232. direction2: Vector3;
  12233. /**
  12234. * 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.
  12235. */
  12236. minEmitBox: Vector3;
  12237. /**
  12238. * 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.
  12239. */
  12240. maxEmitBox: Vector3;
  12241. /**
  12242. * Creates a new instance BoxParticleEmitter
  12243. */
  12244. constructor();
  12245. /**
  12246. * Called by the particle System when the direction is computed for the created particle.
  12247. * @param worldMatrix is the world matrix of the particle system
  12248. * @param directionToUpdate is the direction vector to update with the result
  12249. * @param particle is the particle we are computed the direction for
  12250. * @param isLocal defines if the direction should be set in local space
  12251. */
  12252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12253. /**
  12254. * Called by the particle System when the position is computed for the created particle.
  12255. * @param worldMatrix is the world matrix of the particle system
  12256. * @param positionToUpdate is the position vector to update with the result
  12257. * @param particle is the particle we are computed the position for
  12258. * @param isLocal defines if the position should be set in local space
  12259. */
  12260. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12261. /**
  12262. * Clones the current emitter and returns a copy of it
  12263. * @returns the new emitter
  12264. */
  12265. clone(): BoxParticleEmitter;
  12266. /**
  12267. * Called by the GPUParticleSystem to setup the update shader
  12268. * @param effect defines the update shader
  12269. */
  12270. applyToShader(effect: Effect): void;
  12271. /**
  12272. * Returns a string to use to update the GPU particles update shader
  12273. * @returns a string containng the defines string
  12274. */
  12275. getEffectDefines(): string;
  12276. /**
  12277. * Returns the string "BoxParticleEmitter"
  12278. * @returns a string containing the class name
  12279. */
  12280. getClassName(): string;
  12281. /**
  12282. * Serializes the particle system to a JSON object.
  12283. * @returns the JSON object
  12284. */
  12285. serialize(): any;
  12286. /**
  12287. * Parse properties from a JSON object
  12288. * @param serializationObject defines the JSON object
  12289. */
  12290. parse(serializationObject: any): void;
  12291. }
  12292. }
  12293. declare module BABYLON {
  12294. /**
  12295. * Particle emitter emitting particles from the inside of a cone.
  12296. * It emits the particles alongside the cone volume from the base to the particle.
  12297. * The emission direction might be randomized.
  12298. */
  12299. export class ConeParticleEmitter implements IParticleEmitterType {
  12300. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12301. directionRandomizer: number;
  12302. private _radius;
  12303. private _angle;
  12304. private _height;
  12305. /**
  12306. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12307. */
  12308. radiusRange: number;
  12309. /**
  12310. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12311. */
  12312. heightRange: number;
  12313. /**
  12314. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12315. */
  12316. emitFromSpawnPointOnly: boolean;
  12317. /**
  12318. * Gets or sets the radius of the emission cone
  12319. */
  12320. get radius(): number;
  12321. set radius(value: number);
  12322. /**
  12323. * Gets or sets the angle of the emission cone
  12324. */
  12325. get angle(): number;
  12326. set angle(value: number);
  12327. private _buildHeight;
  12328. /**
  12329. * Creates a new instance ConeParticleEmitter
  12330. * @param radius the radius of the emission cone (1 by default)
  12331. * @param angle the cone base angle (PI by default)
  12332. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12333. */
  12334. constructor(radius?: number, angle?: number,
  12335. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12336. directionRandomizer?: number);
  12337. /**
  12338. * Called by the particle System when the direction is computed for the created particle.
  12339. * @param worldMatrix is the world matrix of the particle system
  12340. * @param directionToUpdate is the direction vector to update with the result
  12341. * @param particle is the particle we are computed the direction for
  12342. * @param isLocal defines if the direction should be set in local space
  12343. */
  12344. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12345. /**
  12346. * Called by the particle System when the position is computed for the created particle.
  12347. * @param worldMatrix is the world matrix of the particle system
  12348. * @param positionToUpdate is the position vector to update with the result
  12349. * @param particle is the particle we are computed the position for
  12350. * @param isLocal defines if the position should be set in local space
  12351. */
  12352. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12353. /**
  12354. * Clones the current emitter and returns a copy of it
  12355. * @returns the new emitter
  12356. */
  12357. clone(): ConeParticleEmitter;
  12358. /**
  12359. * Called by the GPUParticleSystem to setup the update shader
  12360. * @param effect defines the update shader
  12361. */
  12362. applyToShader(effect: Effect): void;
  12363. /**
  12364. * Returns a string to use to update the GPU particles update shader
  12365. * @returns a string containng the defines string
  12366. */
  12367. getEffectDefines(): string;
  12368. /**
  12369. * Returns the string "ConeParticleEmitter"
  12370. * @returns a string containing the class name
  12371. */
  12372. getClassName(): string;
  12373. /**
  12374. * Serializes the particle system to a JSON object.
  12375. * @returns the JSON object
  12376. */
  12377. serialize(): any;
  12378. /**
  12379. * Parse properties from a JSON object
  12380. * @param serializationObject defines the JSON object
  12381. */
  12382. parse(serializationObject: any): void;
  12383. }
  12384. }
  12385. declare module BABYLON {
  12386. /**
  12387. * Particle emitter emitting particles from the inside of a cylinder.
  12388. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12389. */
  12390. export class CylinderParticleEmitter implements IParticleEmitterType {
  12391. /**
  12392. * The radius of the emission cylinder.
  12393. */
  12394. radius: number;
  12395. /**
  12396. * The height of the emission cylinder.
  12397. */
  12398. height: number;
  12399. /**
  12400. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12401. */
  12402. radiusRange: number;
  12403. /**
  12404. * How much to randomize the particle direction [0-1].
  12405. */
  12406. directionRandomizer: number;
  12407. /**
  12408. * Creates a new instance CylinderParticleEmitter
  12409. * @param radius the radius of the emission cylinder (1 by default)
  12410. * @param height the height of the emission cylinder (1 by default)
  12411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12412. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12413. */
  12414. constructor(
  12415. /**
  12416. * The radius of the emission cylinder.
  12417. */
  12418. radius?: number,
  12419. /**
  12420. * The height of the emission cylinder.
  12421. */
  12422. height?: number,
  12423. /**
  12424. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12425. */
  12426. radiusRange?: number,
  12427. /**
  12428. * How much to randomize the particle direction [0-1].
  12429. */
  12430. directionRandomizer?: number);
  12431. /**
  12432. * Called by the particle System when the direction is computed for the created particle.
  12433. * @param worldMatrix is the world matrix of the particle system
  12434. * @param directionToUpdate is the direction vector to update with the result
  12435. * @param particle is the particle we are computed the direction for
  12436. * @param isLocal defines if the direction should be set in local space
  12437. */
  12438. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12439. /**
  12440. * Called by the particle System when the position is computed for the created particle.
  12441. * @param worldMatrix is the world matrix of the particle system
  12442. * @param positionToUpdate is the position vector to update with the result
  12443. * @param particle is the particle we are computed the position for
  12444. * @param isLocal defines if the position should be set in local space
  12445. */
  12446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12447. /**
  12448. * Clones the current emitter and returns a copy of it
  12449. * @returns the new emitter
  12450. */
  12451. clone(): CylinderParticleEmitter;
  12452. /**
  12453. * Called by the GPUParticleSystem to setup the update shader
  12454. * @param effect defines the update shader
  12455. */
  12456. applyToShader(effect: Effect): void;
  12457. /**
  12458. * Returns a string to use to update the GPU particles update shader
  12459. * @returns a string containng the defines string
  12460. */
  12461. getEffectDefines(): string;
  12462. /**
  12463. * Returns the string "CylinderParticleEmitter"
  12464. * @returns a string containing the class name
  12465. */
  12466. getClassName(): string;
  12467. /**
  12468. * Serializes the particle system to a JSON object.
  12469. * @returns the JSON object
  12470. */
  12471. serialize(): any;
  12472. /**
  12473. * Parse properties from a JSON object
  12474. * @param serializationObject defines the JSON object
  12475. */
  12476. parse(serializationObject: any): void;
  12477. }
  12478. /**
  12479. * Particle emitter emitting particles from the inside of a cylinder.
  12480. * It emits the particles randomly between two vectors.
  12481. */
  12482. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12483. /**
  12484. * The min limit of the emission direction.
  12485. */
  12486. direction1: Vector3;
  12487. /**
  12488. * The max limit of the emission direction.
  12489. */
  12490. direction2: Vector3;
  12491. /**
  12492. * Creates a new instance CylinderDirectedParticleEmitter
  12493. * @param radius the radius of the emission cylinder (1 by default)
  12494. * @param height the height of the emission cylinder (1 by default)
  12495. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12496. * @param direction1 the min limit of the emission direction (up vector by default)
  12497. * @param direction2 the max limit of the emission direction (up vector by default)
  12498. */
  12499. constructor(radius?: number, height?: number, radiusRange?: number,
  12500. /**
  12501. * The min limit of the emission direction.
  12502. */
  12503. direction1?: Vector3,
  12504. /**
  12505. * The max limit of the emission direction.
  12506. */
  12507. direction2?: Vector3);
  12508. /**
  12509. * Called by the particle System when the direction is computed for the created particle.
  12510. * @param worldMatrix is the world matrix of the particle system
  12511. * @param directionToUpdate is the direction vector to update with the result
  12512. * @param particle is the particle we are computed the direction for
  12513. */
  12514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12515. /**
  12516. * Clones the current emitter and returns a copy of it
  12517. * @returns the new emitter
  12518. */
  12519. clone(): CylinderDirectedParticleEmitter;
  12520. /**
  12521. * Called by the GPUParticleSystem to setup the update shader
  12522. * @param effect defines the update shader
  12523. */
  12524. applyToShader(effect: Effect): void;
  12525. /**
  12526. * Returns a string to use to update the GPU particles update shader
  12527. * @returns a string containng the defines string
  12528. */
  12529. getEffectDefines(): string;
  12530. /**
  12531. * Returns the string "CylinderDirectedParticleEmitter"
  12532. * @returns a string containing the class name
  12533. */
  12534. getClassName(): string;
  12535. /**
  12536. * Serializes the particle system to a JSON object.
  12537. * @returns the JSON object
  12538. */
  12539. serialize(): any;
  12540. /**
  12541. * Parse properties from a JSON object
  12542. * @param serializationObject defines the JSON object
  12543. */
  12544. parse(serializationObject: any): void;
  12545. }
  12546. }
  12547. declare module BABYLON {
  12548. /**
  12549. * Particle emitter emitting particles from the inside of a hemisphere.
  12550. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12551. */
  12552. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12553. /**
  12554. * The radius of the emission hemisphere.
  12555. */
  12556. radius: number;
  12557. /**
  12558. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12559. */
  12560. radiusRange: number;
  12561. /**
  12562. * How much to randomize the particle direction [0-1].
  12563. */
  12564. directionRandomizer: number;
  12565. /**
  12566. * Creates a new instance HemisphericParticleEmitter
  12567. * @param radius the radius of the emission hemisphere (1 by default)
  12568. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12569. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12570. */
  12571. constructor(
  12572. /**
  12573. * The radius of the emission hemisphere.
  12574. */
  12575. radius?: number,
  12576. /**
  12577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12578. */
  12579. radiusRange?: number,
  12580. /**
  12581. * How much to randomize the particle direction [0-1].
  12582. */
  12583. directionRandomizer?: number);
  12584. /**
  12585. * Called by the particle System when the direction is computed for the created particle.
  12586. * @param worldMatrix is the world matrix of the particle system
  12587. * @param directionToUpdate is the direction vector to update with the result
  12588. * @param particle is the particle we are computed the direction for
  12589. * @param isLocal defines if the direction should be set in local space
  12590. */
  12591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12592. /**
  12593. * Called by the particle System when the position is computed for the created particle.
  12594. * @param worldMatrix is the world matrix of the particle system
  12595. * @param positionToUpdate is the position vector to update with the result
  12596. * @param particle is the particle we are computed the position for
  12597. * @param isLocal defines if the position should be set in local space
  12598. */
  12599. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12600. /**
  12601. * Clones the current emitter and returns a copy of it
  12602. * @returns the new emitter
  12603. */
  12604. clone(): HemisphericParticleEmitter;
  12605. /**
  12606. * Called by the GPUParticleSystem to setup the update shader
  12607. * @param effect defines the update shader
  12608. */
  12609. applyToShader(effect: Effect): void;
  12610. /**
  12611. * Returns a string to use to update the GPU particles update shader
  12612. * @returns a string containng the defines string
  12613. */
  12614. getEffectDefines(): string;
  12615. /**
  12616. * Returns the string "HemisphericParticleEmitter"
  12617. * @returns a string containing the class name
  12618. */
  12619. getClassName(): string;
  12620. /**
  12621. * Serializes the particle system to a JSON object.
  12622. * @returns the JSON object
  12623. */
  12624. serialize(): any;
  12625. /**
  12626. * Parse properties from a JSON object
  12627. * @param serializationObject defines the JSON object
  12628. */
  12629. parse(serializationObject: any): void;
  12630. }
  12631. }
  12632. declare module BABYLON {
  12633. /**
  12634. * Particle emitter emitting particles from a point.
  12635. * It emits the particles randomly between 2 given directions.
  12636. */
  12637. export class PointParticleEmitter implements IParticleEmitterType {
  12638. /**
  12639. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12640. */
  12641. direction1: Vector3;
  12642. /**
  12643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12644. */
  12645. direction2: Vector3;
  12646. /**
  12647. * Creates a new instance PointParticleEmitter
  12648. */
  12649. constructor();
  12650. /**
  12651. * Called by the particle System when the direction is computed for the created particle.
  12652. * @param worldMatrix is the world matrix of the particle system
  12653. * @param directionToUpdate is the direction vector to update with the result
  12654. * @param particle is the particle we are computed the direction for
  12655. * @param isLocal defines if the direction should be set in local space
  12656. */
  12657. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12658. /**
  12659. * Called by the particle System when the position is computed for the created particle.
  12660. * @param worldMatrix is the world matrix of the particle system
  12661. * @param positionToUpdate is the position vector to update with the result
  12662. * @param particle is the particle we are computed the position for
  12663. * @param isLocal defines if the position should be set in local space
  12664. */
  12665. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12666. /**
  12667. * Clones the current emitter and returns a copy of it
  12668. * @returns the new emitter
  12669. */
  12670. clone(): PointParticleEmitter;
  12671. /**
  12672. * Called by the GPUParticleSystem to setup the update shader
  12673. * @param effect defines the update shader
  12674. */
  12675. applyToShader(effect: Effect): void;
  12676. /**
  12677. * Returns a string to use to update the GPU particles update shader
  12678. * @returns a string containng the defines string
  12679. */
  12680. getEffectDefines(): string;
  12681. /**
  12682. * Returns the string "PointParticleEmitter"
  12683. * @returns a string containing the class name
  12684. */
  12685. getClassName(): string;
  12686. /**
  12687. * Serializes the particle system to a JSON object.
  12688. * @returns the JSON object
  12689. */
  12690. serialize(): any;
  12691. /**
  12692. * Parse properties from a JSON object
  12693. * @param serializationObject defines the JSON object
  12694. */
  12695. parse(serializationObject: any): void;
  12696. }
  12697. }
  12698. declare module BABYLON {
  12699. /**
  12700. * Particle emitter emitting particles from the inside of a sphere.
  12701. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12702. */
  12703. export class SphereParticleEmitter implements IParticleEmitterType {
  12704. /**
  12705. * The radius of the emission sphere.
  12706. */
  12707. radius: number;
  12708. /**
  12709. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12710. */
  12711. radiusRange: number;
  12712. /**
  12713. * How much to randomize the particle direction [0-1].
  12714. */
  12715. directionRandomizer: number;
  12716. /**
  12717. * Creates a new instance SphereParticleEmitter
  12718. * @param radius the radius of the emission sphere (1 by default)
  12719. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12720. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12721. */
  12722. constructor(
  12723. /**
  12724. * The radius of the emission sphere.
  12725. */
  12726. radius?: number,
  12727. /**
  12728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12729. */
  12730. radiusRange?: number,
  12731. /**
  12732. * How much to randomize the particle direction [0-1].
  12733. */
  12734. directionRandomizer?: number);
  12735. /**
  12736. * Called by the particle System when the direction is computed for the created particle.
  12737. * @param worldMatrix is the world matrix of the particle system
  12738. * @param directionToUpdate is the direction vector to update with the result
  12739. * @param particle is the particle we are computed the direction for
  12740. * @param isLocal defines if the direction should be set in local space
  12741. */
  12742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12743. /**
  12744. * Called by the particle System when the position is computed for the created particle.
  12745. * @param worldMatrix is the world matrix of the particle system
  12746. * @param positionToUpdate is the position vector to update with the result
  12747. * @param particle is the particle we are computed the position for
  12748. * @param isLocal defines if the position should be set in local space
  12749. */
  12750. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12751. /**
  12752. * Clones the current emitter and returns a copy of it
  12753. * @returns the new emitter
  12754. */
  12755. clone(): SphereParticleEmitter;
  12756. /**
  12757. * Called by the GPUParticleSystem to setup the update shader
  12758. * @param effect defines the update shader
  12759. */
  12760. applyToShader(effect: Effect): void;
  12761. /**
  12762. * Returns a string to use to update the GPU particles update shader
  12763. * @returns a string containng the defines string
  12764. */
  12765. getEffectDefines(): string;
  12766. /**
  12767. * Returns the string "SphereParticleEmitter"
  12768. * @returns a string containing the class name
  12769. */
  12770. getClassName(): string;
  12771. /**
  12772. * Serializes the particle system to a JSON object.
  12773. * @returns the JSON object
  12774. */
  12775. serialize(): any;
  12776. /**
  12777. * Parse properties from a JSON object
  12778. * @param serializationObject defines the JSON object
  12779. */
  12780. parse(serializationObject: any): void;
  12781. }
  12782. /**
  12783. * Particle emitter emitting particles from the inside of a sphere.
  12784. * It emits the particles randomly between two vectors.
  12785. */
  12786. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12787. /**
  12788. * The min limit of the emission direction.
  12789. */
  12790. direction1: Vector3;
  12791. /**
  12792. * The max limit of the emission direction.
  12793. */
  12794. direction2: Vector3;
  12795. /**
  12796. * Creates a new instance SphereDirectedParticleEmitter
  12797. * @param radius the radius of the emission sphere (1 by default)
  12798. * @param direction1 the min limit of the emission direction (up vector by default)
  12799. * @param direction2 the max limit of the emission direction (up vector by default)
  12800. */
  12801. constructor(radius?: number,
  12802. /**
  12803. * The min limit of the emission direction.
  12804. */
  12805. direction1?: Vector3,
  12806. /**
  12807. * The max limit of the emission direction.
  12808. */
  12809. direction2?: Vector3);
  12810. /**
  12811. * Called by the particle System when the direction is computed for the created particle.
  12812. * @param worldMatrix is the world matrix of the particle system
  12813. * @param directionToUpdate is the direction vector to update with the result
  12814. * @param particle is the particle we are computed the direction for
  12815. */
  12816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12817. /**
  12818. * Clones the current emitter and returns a copy of it
  12819. * @returns the new emitter
  12820. */
  12821. clone(): SphereDirectedParticleEmitter;
  12822. /**
  12823. * Called by the GPUParticleSystem to setup the update shader
  12824. * @param effect defines the update shader
  12825. */
  12826. applyToShader(effect: Effect): void;
  12827. /**
  12828. * Returns a string to use to update the GPU particles update shader
  12829. * @returns a string containng the defines string
  12830. */
  12831. getEffectDefines(): string;
  12832. /**
  12833. * Returns the string "SphereDirectedParticleEmitter"
  12834. * @returns a string containing the class name
  12835. */
  12836. getClassName(): string;
  12837. /**
  12838. * Serializes the particle system to a JSON object.
  12839. * @returns the JSON object
  12840. */
  12841. serialize(): any;
  12842. /**
  12843. * Parse properties from a JSON object
  12844. * @param serializationObject defines the JSON object
  12845. */
  12846. parse(serializationObject: any): void;
  12847. }
  12848. }
  12849. declare module BABYLON {
  12850. /**
  12851. * Particle emitter emitting particles from a custom list of positions.
  12852. */
  12853. export class CustomParticleEmitter implements IParticleEmitterType {
  12854. /**
  12855. * Gets or sets the position generator that will create the inital position of each particle.
  12856. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12857. */
  12858. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12859. /**
  12860. * Gets or sets the destination generator that will create the final destination of each particle.
  12861. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12862. */
  12863. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12864. /**
  12865. * Creates a new instance CustomParticleEmitter
  12866. */
  12867. constructor();
  12868. /**
  12869. * Called by the particle System when the direction is computed for the created particle.
  12870. * @param worldMatrix is the world matrix of the particle system
  12871. * @param directionToUpdate is the direction vector to update with the result
  12872. * @param particle is the particle we are computed the direction for
  12873. * @param isLocal defines if the direction should be set in local space
  12874. */
  12875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12876. /**
  12877. * Called by the particle System when the position is computed for the created particle.
  12878. * @param worldMatrix is the world matrix of the particle system
  12879. * @param positionToUpdate is the position vector to update with the result
  12880. * @param particle is the particle we are computed the position for
  12881. * @param isLocal defines if the position should be set in local space
  12882. */
  12883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12884. /**
  12885. * Clones the current emitter and returns a copy of it
  12886. * @returns the new emitter
  12887. */
  12888. clone(): CustomParticleEmitter;
  12889. /**
  12890. * Called by the GPUParticleSystem to setup the update shader
  12891. * @param effect defines the update shader
  12892. */
  12893. applyToShader(effect: Effect): void;
  12894. /**
  12895. * Returns a string to use to update the GPU particles update shader
  12896. * @returns a string containng the defines string
  12897. */
  12898. getEffectDefines(): string;
  12899. /**
  12900. * Returns the string "PointParticleEmitter"
  12901. * @returns a string containing the class name
  12902. */
  12903. getClassName(): string;
  12904. /**
  12905. * Serializes the particle system to a JSON object.
  12906. * @returns the JSON object
  12907. */
  12908. serialize(): any;
  12909. /**
  12910. * Parse properties from a JSON object
  12911. * @param serializationObject defines the JSON object
  12912. */
  12913. parse(serializationObject: any): void;
  12914. }
  12915. }
  12916. declare module BABYLON {
  12917. /**
  12918. * Particle emitter emitting particles from the inside of a box.
  12919. * It emits the particles randomly between 2 given directions.
  12920. */
  12921. export class MeshParticleEmitter implements IParticleEmitterType {
  12922. private _indices;
  12923. private _positions;
  12924. private _normals;
  12925. private _storedNormal;
  12926. private _mesh;
  12927. /**
  12928. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12929. */
  12930. direction1: Vector3;
  12931. /**
  12932. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12933. */
  12934. direction2: Vector3;
  12935. /**
  12936. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12937. */
  12938. useMeshNormalsForDirection: boolean;
  12939. /** Defines the mesh to use as source */
  12940. get mesh(): Nullable<AbstractMesh>;
  12941. set mesh(value: Nullable<AbstractMesh>);
  12942. /**
  12943. * Creates a new instance MeshParticleEmitter
  12944. * @param mesh defines the mesh to use as source
  12945. */
  12946. constructor(mesh?: Nullable<AbstractMesh>);
  12947. /**
  12948. * Called by the particle System when the direction is computed for the created particle.
  12949. * @param worldMatrix is the world matrix of the particle system
  12950. * @param directionToUpdate is the direction vector to update with the result
  12951. * @param particle is the particle we are computed the direction for
  12952. * @param isLocal defines if the direction should be set in local space
  12953. */
  12954. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12955. /**
  12956. * Called by the particle System when the position is computed for the created particle.
  12957. * @param worldMatrix is the world matrix of the particle system
  12958. * @param positionToUpdate is the position vector to update with the result
  12959. * @param particle is the particle we are computed the position for
  12960. * @param isLocal defines if the position should be set in local space
  12961. */
  12962. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12963. /**
  12964. * Clones the current emitter and returns a copy of it
  12965. * @returns the new emitter
  12966. */
  12967. clone(): MeshParticleEmitter;
  12968. /**
  12969. * Called by the GPUParticleSystem to setup the update shader
  12970. * @param effect defines the update shader
  12971. */
  12972. applyToShader(effect: Effect): void;
  12973. /**
  12974. * Returns a string to use to update the GPU particles update shader
  12975. * @returns a string containng the defines string
  12976. */
  12977. getEffectDefines(): string;
  12978. /**
  12979. * Returns the string "BoxParticleEmitter"
  12980. * @returns a string containing the class name
  12981. */
  12982. getClassName(): string;
  12983. /**
  12984. * Serializes the particle system to a JSON object.
  12985. * @returns the JSON object
  12986. */
  12987. serialize(): any;
  12988. /**
  12989. * Parse properties from a JSON object
  12990. * @param serializationObject defines the JSON object
  12991. * @param scene defines the hosting scene
  12992. */
  12993. parse(serializationObject: any, scene: Scene): void;
  12994. }
  12995. }
  12996. declare module BABYLON {
  12997. /**
  12998. * Interface representing a particle system in Babylon.js.
  12999. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13000. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13001. */
  13002. export interface IParticleSystem {
  13003. /**
  13004. * List of animations used by the particle system.
  13005. */
  13006. animations: Animation[];
  13007. /**
  13008. * The id of the Particle system.
  13009. */
  13010. id: string;
  13011. /**
  13012. * The name of the Particle system.
  13013. */
  13014. name: string;
  13015. /**
  13016. * The emitter represents the Mesh or position we are attaching the particle system to.
  13017. */
  13018. emitter: Nullable<AbstractMesh | Vector3>;
  13019. /**
  13020. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13021. */
  13022. isBillboardBased: boolean;
  13023. /**
  13024. * The rendering group used by the Particle system to chose when to render.
  13025. */
  13026. renderingGroupId: number;
  13027. /**
  13028. * The layer mask we are rendering the particles through.
  13029. */
  13030. layerMask: number;
  13031. /**
  13032. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13033. */
  13034. updateSpeed: number;
  13035. /**
  13036. * The amount of time the particle system is running (depends of the overall update speed).
  13037. */
  13038. targetStopDuration: number;
  13039. /**
  13040. * The texture used to render each particle. (this can be a spritesheet)
  13041. */
  13042. particleTexture: Nullable<Texture>;
  13043. /**
  13044. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13045. */
  13046. blendMode: number;
  13047. /**
  13048. * Minimum life time of emitting particles.
  13049. */
  13050. minLifeTime: number;
  13051. /**
  13052. * Maximum life time of emitting particles.
  13053. */
  13054. maxLifeTime: number;
  13055. /**
  13056. * Minimum Size of emitting particles.
  13057. */
  13058. minSize: number;
  13059. /**
  13060. * Maximum Size of emitting particles.
  13061. */
  13062. maxSize: number;
  13063. /**
  13064. * Minimum scale of emitting particles on X axis.
  13065. */
  13066. minScaleX: number;
  13067. /**
  13068. * Maximum scale of emitting particles on X axis.
  13069. */
  13070. maxScaleX: number;
  13071. /**
  13072. * Minimum scale of emitting particles on Y axis.
  13073. */
  13074. minScaleY: number;
  13075. /**
  13076. * Maximum scale of emitting particles on Y axis.
  13077. */
  13078. maxScaleY: number;
  13079. /**
  13080. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13081. */
  13082. color1: Color4;
  13083. /**
  13084. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13085. */
  13086. color2: Color4;
  13087. /**
  13088. * Color the particle will have at the end of its lifetime.
  13089. */
  13090. colorDead: Color4;
  13091. /**
  13092. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13093. */
  13094. emitRate: number;
  13095. /**
  13096. * You can use gravity if you want to give an orientation to your particles.
  13097. */
  13098. gravity: Vector3;
  13099. /**
  13100. * Minimum power of emitting particles.
  13101. */
  13102. minEmitPower: number;
  13103. /**
  13104. * Maximum power of emitting particles.
  13105. */
  13106. maxEmitPower: number;
  13107. /**
  13108. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13109. */
  13110. minAngularSpeed: number;
  13111. /**
  13112. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13113. */
  13114. maxAngularSpeed: number;
  13115. /**
  13116. * Gets or sets the minimal initial rotation in radians.
  13117. */
  13118. minInitialRotation: number;
  13119. /**
  13120. * Gets or sets the maximal initial rotation in radians.
  13121. */
  13122. maxInitialRotation: number;
  13123. /**
  13124. * The particle emitter type defines the emitter used by the particle system.
  13125. * It can be for example box, sphere, or cone...
  13126. */
  13127. particleEmitterType: Nullable<IParticleEmitterType>;
  13128. /**
  13129. * Defines the delay in milliseconds before starting the system (0 by default)
  13130. */
  13131. startDelay: number;
  13132. /**
  13133. * 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
  13134. */
  13135. preWarmCycles: number;
  13136. /**
  13137. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13138. */
  13139. preWarmStepOffset: number;
  13140. /**
  13141. * 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)
  13142. */
  13143. spriteCellChangeSpeed: number;
  13144. /**
  13145. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13146. */
  13147. startSpriteCellID: number;
  13148. /**
  13149. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13150. */
  13151. endSpriteCellID: number;
  13152. /**
  13153. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13154. */
  13155. spriteCellWidth: number;
  13156. /**
  13157. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13158. */
  13159. spriteCellHeight: number;
  13160. /**
  13161. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13162. */
  13163. spriteRandomStartCell: boolean;
  13164. /**
  13165. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13166. */
  13167. isAnimationSheetEnabled: boolean;
  13168. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13169. translationPivot: Vector2;
  13170. /**
  13171. * Gets or sets a texture used to add random noise to particle positions
  13172. */
  13173. noiseTexture: Nullable<BaseTexture>;
  13174. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13175. noiseStrength: Vector3;
  13176. /**
  13177. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13178. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13179. */
  13180. billboardMode: number;
  13181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13182. limitVelocityDamping: number;
  13183. /**
  13184. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13185. */
  13186. beginAnimationOnStart: boolean;
  13187. /**
  13188. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13189. */
  13190. beginAnimationFrom: number;
  13191. /**
  13192. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13193. */
  13194. beginAnimationTo: number;
  13195. /**
  13196. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13197. */
  13198. beginAnimationLoop: boolean;
  13199. /**
  13200. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13201. */
  13202. disposeOnStop: boolean;
  13203. /**
  13204. * Specifies if the particles are updated in emitter local space or world space
  13205. */
  13206. isLocal: boolean;
  13207. /** Snippet ID if the particle system was created from the snippet server */
  13208. snippetId: string;
  13209. /**
  13210. * Gets the maximum number of particles active at the same time.
  13211. * @returns The max number of active particles.
  13212. */
  13213. getCapacity(): number;
  13214. /**
  13215. * Gets the number of particles active at the same time.
  13216. * @returns The number of active particles.
  13217. */
  13218. getActiveCount(): number;
  13219. /**
  13220. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13221. * @returns True if it has been started, otherwise false.
  13222. */
  13223. isStarted(): boolean;
  13224. /**
  13225. * Animates the particle system for this frame.
  13226. */
  13227. animate(): void;
  13228. /**
  13229. * Renders the particle system in its current state.
  13230. * @returns the current number of particles
  13231. */
  13232. render(): number;
  13233. /**
  13234. * Dispose the particle system and frees its associated resources.
  13235. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13236. */
  13237. dispose(disposeTexture?: boolean): void;
  13238. /**
  13239. * Clones the particle system.
  13240. * @param name The name of the cloned object
  13241. * @param newEmitter The new emitter to use
  13242. * @returns the cloned particle system
  13243. */
  13244. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13245. /**
  13246. * Serializes the particle system to a JSON object.
  13247. * @returns the JSON object
  13248. */
  13249. serialize(): any;
  13250. /**
  13251. * Rebuild the particle system
  13252. */
  13253. rebuild(): void;
  13254. /**
  13255. * Starts the particle system and begins to emit
  13256. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13257. */
  13258. start(delay?: number): void;
  13259. /**
  13260. * Stops the particle system.
  13261. */
  13262. stop(): void;
  13263. /**
  13264. * Remove all active particles
  13265. */
  13266. reset(): void;
  13267. /**
  13268. * Gets a boolean indicating that the system is stopping
  13269. * @returns true if the system is currently stopping
  13270. */
  13271. isStopping(): boolean;
  13272. /**
  13273. * Is this system ready to be used/rendered
  13274. * @return true if the system is ready
  13275. */
  13276. isReady(): boolean;
  13277. /**
  13278. * Returns the string "ParticleSystem"
  13279. * @returns a string containing the class name
  13280. */
  13281. getClassName(): string;
  13282. /**
  13283. * Adds a new color gradient
  13284. * @param gradient defines the gradient to use (between 0 and 1)
  13285. * @param color1 defines the color to affect to the specified gradient
  13286. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13287. * @returns the current particle system
  13288. */
  13289. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13290. /**
  13291. * Remove a specific color gradient
  13292. * @param gradient defines the gradient to remove
  13293. * @returns the current particle system
  13294. */
  13295. removeColorGradient(gradient: number): IParticleSystem;
  13296. /**
  13297. * Adds a new size gradient
  13298. * @param gradient defines the gradient to use (between 0 and 1)
  13299. * @param factor defines the size factor to affect to the specified gradient
  13300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13301. * @returns the current particle system
  13302. */
  13303. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13304. /**
  13305. * Remove a specific size gradient
  13306. * @param gradient defines the gradient to remove
  13307. * @returns the current particle system
  13308. */
  13309. removeSizeGradient(gradient: number): IParticleSystem;
  13310. /**
  13311. * Gets the current list of color gradients.
  13312. * You must use addColorGradient and removeColorGradient to udpate this list
  13313. * @returns the list of color gradients
  13314. */
  13315. getColorGradients(): Nullable<Array<ColorGradient>>;
  13316. /**
  13317. * Gets the current list of size gradients.
  13318. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13319. * @returns the list of size gradients
  13320. */
  13321. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13322. /**
  13323. * Gets the current list of angular speed gradients.
  13324. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13325. * @returns the list of angular speed gradients
  13326. */
  13327. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13328. /**
  13329. * Adds a new angular speed gradient
  13330. * @param gradient defines the gradient to use (between 0 and 1)
  13331. * @param factor defines the angular speed to affect to the specified gradient
  13332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13333. * @returns the current particle system
  13334. */
  13335. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13336. /**
  13337. * Remove a specific angular speed gradient
  13338. * @param gradient defines the gradient to remove
  13339. * @returns the current particle system
  13340. */
  13341. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13342. /**
  13343. * Gets the current list of velocity gradients.
  13344. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13345. * @returns the list of velocity gradients
  13346. */
  13347. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13348. /**
  13349. * Adds a new velocity gradient
  13350. * @param gradient defines the gradient to use (between 0 and 1)
  13351. * @param factor defines the velocity to affect to the specified gradient
  13352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13353. * @returns the current particle system
  13354. */
  13355. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13356. /**
  13357. * Remove a specific velocity gradient
  13358. * @param gradient defines the gradient to remove
  13359. * @returns the current particle system
  13360. */
  13361. removeVelocityGradient(gradient: number): IParticleSystem;
  13362. /**
  13363. * Gets the current list of limit velocity gradients.
  13364. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13365. * @returns the list of limit velocity gradients
  13366. */
  13367. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13368. /**
  13369. * Adds a new limit velocity gradient
  13370. * @param gradient defines the gradient to use (between 0 and 1)
  13371. * @param factor defines the limit velocity to affect to the specified gradient
  13372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13373. * @returns the current particle system
  13374. */
  13375. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13376. /**
  13377. * Remove a specific limit velocity gradient
  13378. * @param gradient defines the gradient to remove
  13379. * @returns the current particle system
  13380. */
  13381. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13382. /**
  13383. * Adds a new drag gradient
  13384. * @param gradient defines the gradient to use (between 0 and 1)
  13385. * @param factor defines the drag to affect to the specified gradient
  13386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13387. * @returns the current particle system
  13388. */
  13389. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13390. /**
  13391. * Remove a specific drag gradient
  13392. * @param gradient defines the gradient to remove
  13393. * @returns the current particle system
  13394. */
  13395. removeDragGradient(gradient: number): IParticleSystem;
  13396. /**
  13397. * Gets the current list of drag gradients.
  13398. * You must use addDragGradient and removeDragGradient to udpate this list
  13399. * @returns the list of drag gradients
  13400. */
  13401. getDragGradients(): Nullable<Array<FactorGradient>>;
  13402. /**
  13403. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13404. * @param gradient defines the gradient to use (between 0 and 1)
  13405. * @param factor defines the emit rate to affect to the specified gradient
  13406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13407. * @returns the current particle system
  13408. */
  13409. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13410. /**
  13411. * Remove a specific emit rate gradient
  13412. * @param gradient defines the gradient to remove
  13413. * @returns the current particle system
  13414. */
  13415. removeEmitRateGradient(gradient: number): IParticleSystem;
  13416. /**
  13417. * Gets the current list of emit rate gradients.
  13418. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13419. * @returns the list of emit rate gradients
  13420. */
  13421. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13422. /**
  13423. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13424. * @param gradient defines the gradient to use (between 0 and 1)
  13425. * @param factor defines the start size to affect to the specified gradient
  13426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13427. * @returns the current particle system
  13428. */
  13429. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13430. /**
  13431. * Remove a specific start size gradient
  13432. * @param gradient defines the gradient to remove
  13433. * @returns the current particle system
  13434. */
  13435. removeStartSizeGradient(gradient: number): IParticleSystem;
  13436. /**
  13437. * Gets the current list of start size gradients.
  13438. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13439. * @returns the list of start size gradients
  13440. */
  13441. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13442. /**
  13443. * Adds a new life time gradient
  13444. * @param gradient defines the gradient to use (between 0 and 1)
  13445. * @param factor defines the life time factor to affect to the specified gradient
  13446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13447. * @returns the current particle system
  13448. */
  13449. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13450. /**
  13451. * Remove a specific life time gradient
  13452. * @param gradient defines the gradient to remove
  13453. * @returns the current particle system
  13454. */
  13455. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13456. /**
  13457. * Gets the current list of life time gradients.
  13458. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13459. * @returns the list of life time gradients
  13460. */
  13461. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13462. /**
  13463. * Gets the current list of color gradients.
  13464. * You must use addColorGradient and removeColorGradient to udpate this list
  13465. * @returns the list of color gradients
  13466. */
  13467. getColorGradients(): Nullable<Array<ColorGradient>>;
  13468. /**
  13469. * Adds a new ramp gradient used to remap particle colors
  13470. * @param gradient defines the gradient to use (between 0 and 1)
  13471. * @param color defines the color to affect to the specified gradient
  13472. * @returns the current particle system
  13473. */
  13474. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13475. /**
  13476. * Gets the current list of ramp gradients.
  13477. * You must use addRampGradient and removeRampGradient to udpate this list
  13478. * @returns the list of ramp gradients
  13479. */
  13480. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13481. /** Gets or sets a boolean indicating that ramp gradients must be used
  13482. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13483. */
  13484. useRampGradients: boolean;
  13485. /**
  13486. * Adds a new color remap gradient
  13487. * @param gradient defines the gradient to use (between 0 and 1)
  13488. * @param min defines the color remap minimal range
  13489. * @param max defines the color remap maximal range
  13490. * @returns the current particle system
  13491. */
  13492. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13493. /**
  13494. * Gets the current list of color remap gradients.
  13495. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13496. * @returns the list of color remap gradients
  13497. */
  13498. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13499. /**
  13500. * Adds a new alpha remap gradient
  13501. * @param gradient defines the gradient to use (between 0 and 1)
  13502. * @param min defines the alpha remap minimal range
  13503. * @param max defines the alpha remap maximal range
  13504. * @returns the current particle system
  13505. */
  13506. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13507. /**
  13508. * Gets the current list of alpha remap gradients.
  13509. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13510. * @returns the list of alpha remap gradients
  13511. */
  13512. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13513. /**
  13514. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13517. * @returns the emitter
  13518. */
  13519. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13520. /**
  13521. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13522. * @param radius The radius of the hemisphere to emit from
  13523. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13524. * @returns the emitter
  13525. */
  13526. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13527. /**
  13528. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13529. * @param radius The radius of the sphere to emit from
  13530. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13531. * @returns the emitter
  13532. */
  13533. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13534. /**
  13535. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13536. * @param radius The radius of the sphere to emit from
  13537. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13538. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13539. * @returns the emitter
  13540. */
  13541. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13542. /**
  13543. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13544. * @param radius The radius of the emission cylinder
  13545. * @param height The height of the emission cylinder
  13546. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13547. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13548. * @returns the emitter
  13549. */
  13550. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13551. /**
  13552. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13553. * @param radius The radius of the cylinder to emit from
  13554. * @param height The height of the emission cylinder
  13555. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13558. * @returns the emitter
  13559. */
  13560. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13561. /**
  13562. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13563. * @param radius The radius of the cone to emit from
  13564. * @param angle The base angle of the cone
  13565. * @returns the emitter
  13566. */
  13567. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13568. /**
  13569. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13572. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13573. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13574. * @returns the emitter
  13575. */
  13576. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13577. /**
  13578. * Get hosting scene
  13579. * @returns the scene
  13580. */
  13581. getScene(): Scene;
  13582. }
  13583. }
  13584. declare module BABYLON {
  13585. /**
  13586. * 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.
  13587. * @see https://doc.babylonjs.com/how_to/transformnode
  13588. */
  13589. export class TransformNode extends Node {
  13590. /**
  13591. * Object will not rotate to face the camera
  13592. */
  13593. static BILLBOARDMODE_NONE: number;
  13594. /**
  13595. * Object will rotate to face the camera but only on the x axis
  13596. */
  13597. static BILLBOARDMODE_X: number;
  13598. /**
  13599. * Object will rotate to face the camera but only on the y axis
  13600. */
  13601. static BILLBOARDMODE_Y: number;
  13602. /**
  13603. * Object will rotate to face the camera but only on the z axis
  13604. */
  13605. static BILLBOARDMODE_Z: number;
  13606. /**
  13607. * Object will rotate to face the camera
  13608. */
  13609. static BILLBOARDMODE_ALL: number;
  13610. /**
  13611. * Object will rotate to face the camera's position instead of orientation
  13612. */
  13613. static BILLBOARDMODE_USE_POSITION: number;
  13614. private _forward;
  13615. private _forwardInverted;
  13616. private _up;
  13617. private _right;
  13618. private _rightInverted;
  13619. private _position;
  13620. private _rotation;
  13621. private _rotationQuaternion;
  13622. protected _scaling: Vector3;
  13623. protected _isDirty: boolean;
  13624. private _transformToBoneReferal;
  13625. private _isAbsoluteSynced;
  13626. private _billboardMode;
  13627. /**
  13628. * Gets or sets the billboard mode. Default is 0.
  13629. *
  13630. * | Value | Type | Description |
  13631. * | --- | --- | --- |
  13632. * | 0 | BILLBOARDMODE_NONE | |
  13633. * | 1 | BILLBOARDMODE_X | |
  13634. * | 2 | BILLBOARDMODE_Y | |
  13635. * | 4 | BILLBOARDMODE_Z | |
  13636. * | 7 | BILLBOARDMODE_ALL | |
  13637. *
  13638. */
  13639. get billboardMode(): number;
  13640. set billboardMode(value: number);
  13641. private _preserveParentRotationForBillboard;
  13642. /**
  13643. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13644. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13645. */
  13646. get preserveParentRotationForBillboard(): boolean;
  13647. set preserveParentRotationForBillboard(value: boolean);
  13648. /**
  13649. * 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
  13650. */
  13651. scalingDeterminant: number;
  13652. private _infiniteDistance;
  13653. /**
  13654. * Gets or sets the distance of the object to max, often used by skybox
  13655. */
  13656. get infiniteDistance(): boolean;
  13657. set infiniteDistance(value: boolean);
  13658. /**
  13659. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13660. * By default the system will update normals to compensate
  13661. */
  13662. ignoreNonUniformScaling: boolean;
  13663. /**
  13664. * 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
  13665. */
  13666. reIntegrateRotationIntoRotationQuaternion: boolean;
  13667. /** @hidden */
  13668. _poseMatrix: Nullable<Matrix>;
  13669. /** @hidden */
  13670. _localMatrix: Matrix;
  13671. private _usePivotMatrix;
  13672. private _absolutePosition;
  13673. private _absoluteScaling;
  13674. private _absoluteRotationQuaternion;
  13675. private _pivotMatrix;
  13676. private _pivotMatrixInverse;
  13677. protected _postMultiplyPivotMatrix: boolean;
  13678. protected _isWorldMatrixFrozen: boolean;
  13679. /** @hidden */
  13680. _indexInSceneTransformNodesArray: number;
  13681. /**
  13682. * An event triggered after the world matrix is updated
  13683. */
  13684. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13685. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13686. /**
  13687. * Gets a string identifying the name of the class
  13688. * @returns "TransformNode" string
  13689. */
  13690. getClassName(): string;
  13691. /**
  13692. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13693. */
  13694. get position(): Vector3;
  13695. set position(newPosition: Vector3);
  13696. /**
  13697. * 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)).
  13698. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13699. */
  13700. get rotation(): Vector3;
  13701. set rotation(newRotation: Vector3);
  13702. /**
  13703. * 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)).
  13704. */
  13705. get scaling(): Vector3;
  13706. set scaling(newScaling: Vector3);
  13707. /**
  13708. * 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).
  13709. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13710. */
  13711. get rotationQuaternion(): Nullable<Quaternion>;
  13712. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13713. /**
  13714. * The forward direction of that transform in world space.
  13715. */
  13716. get forward(): Vector3;
  13717. /**
  13718. * The up direction of that transform in world space.
  13719. */
  13720. get up(): Vector3;
  13721. /**
  13722. * The right direction of that transform in world space.
  13723. */
  13724. get right(): Vector3;
  13725. /**
  13726. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13727. * @param matrix the matrix to copy the pose from
  13728. * @returns this TransformNode.
  13729. */
  13730. updatePoseMatrix(matrix: Matrix): TransformNode;
  13731. /**
  13732. * Returns the mesh Pose matrix.
  13733. * @returns the pose matrix
  13734. */
  13735. getPoseMatrix(): Matrix;
  13736. /** @hidden */
  13737. _isSynchronized(): boolean;
  13738. /** @hidden */
  13739. _initCache(): void;
  13740. /**
  13741. * Flag the transform node as dirty (Forcing it to update everything)
  13742. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13743. * @returns this transform node
  13744. */
  13745. markAsDirty(property: string): TransformNode;
  13746. /**
  13747. * Returns the current mesh absolute position.
  13748. * Returns a Vector3.
  13749. */
  13750. get absolutePosition(): Vector3;
  13751. /**
  13752. * Returns the current mesh absolute scaling.
  13753. * Returns a Vector3.
  13754. */
  13755. get absoluteScaling(): Vector3;
  13756. /**
  13757. * Returns the current mesh absolute rotation.
  13758. * Returns a Quaternion.
  13759. */
  13760. get absoluteRotationQuaternion(): Quaternion;
  13761. /**
  13762. * Sets a new matrix to apply before all other transformation
  13763. * @param matrix defines the transform matrix
  13764. * @returns the current TransformNode
  13765. */
  13766. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13767. /**
  13768. * Sets a new pivot matrix to the current node
  13769. * @param matrix defines the new pivot matrix to use
  13770. * @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
  13771. * @returns the current TransformNode
  13772. */
  13773. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13774. /**
  13775. * Returns the mesh pivot matrix.
  13776. * Default : Identity.
  13777. * @returns the matrix
  13778. */
  13779. getPivotMatrix(): Matrix;
  13780. /**
  13781. * Instantiate (when possible) or clone that node with its hierarchy
  13782. * @param newParent defines the new parent to use for the instance (or clone)
  13783. * @param options defines options to configure how copy is done
  13784. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13785. * @returns an instance (or a clone) of the current node with its hiearchy
  13786. */
  13787. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13788. doNotInstantiate: boolean;
  13789. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13790. /**
  13791. * Prevents the World matrix to be computed any longer
  13792. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13793. * @returns the TransformNode.
  13794. */
  13795. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13796. /**
  13797. * Allows back the World matrix computation.
  13798. * @returns the TransformNode.
  13799. */
  13800. unfreezeWorldMatrix(): this;
  13801. /**
  13802. * True if the World matrix has been frozen.
  13803. */
  13804. get isWorldMatrixFrozen(): boolean;
  13805. /**
  13806. * Retuns the mesh absolute position in the World.
  13807. * @returns a Vector3.
  13808. */
  13809. getAbsolutePosition(): Vector3;
  13810. /**
  13811. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13812. * @param absolutePosition the absolute position to set
  13813. * @returns the TransformNode.
  13814. */
  13815. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13816. /**
  13817. * Sets the mesh position in its local space.
  13818. * @param vector3 the position to set in localspace
  13819. * @returns the TransformNode.
  13820. */
  13821. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13822. /**
  13823. * Returns the mesh position in the local space from the current World matrix values.
  13824. * @returns a new Vector3.
  13825. */
  13826. getPositionExpressedInLocalSpace(): Vector3;
  13827. /**
  13828. * Translates the mesh along the passed Vector3 in its local space.
  13829. * @param vector3 the distance to translate in localspace
  13830. * @returns the TransformNode.
  13831. */
  13832. locallyTranslate(vector3: Vector3): TransformNode;
  13833. private static _lookAtVectorCache;
  13834. /**
  13835. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13836. * @param targetPoint the position (must be in same space as current mesh) to look at
  13837. * @param yawCor optional yaw (y-axis) correction in radians
  13838. * @param pitchCor optional pitch (x-axis) correction in radians
  13839. * @param rollCor optional roll (z-axis) correction in radians
  13840. * @param space the choosen space of the target
  13841. * @returns the TransformNode.
  13842. */
  13843. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13844. /**
  13845. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13846. * This Vector3 is expressed in the World space.
  13847. * @param localAxis axis to rotate
  13848. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13849. */
  13850. getDirection(localAxis: Vector3): Vector3;
  13851. /**
  13852. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13853. * localAxis is expressed in the mesh local space.
  13854. * result is computed in the Wordl space from the mesh World matrix.
  13855. * @param localAxis axis to rotate
  13856. * @param result the resulting transformnode
  13857. * @returns this TransformNode.
  13858. */
  13859. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13860. /**
  13861. * Sets this transform node rotation to the given local axis.
  13862. * @param localAxis the axis in local space
  13863. * @param yawCor optional yaw (y-axis) correction in radians
  13864. * @param pitchCor optional pitch (x-axis) correction in radians
  13865. * @param rollCor optional roll (z-axis) correction in radians
  13866. * @returns this TransformNode
  13867. */
  13868. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13869. /**
  13870. * Sets a new pivot point to the current node
  13871. * @param point defines the new pivot point to use
  13872. * @param space defines if the point is in world or local space (local by default)
  13873. * @returns the current TransformNode
  13874. */
  13875. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13876. /**
  13877. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13878. * @returns the pivot point
  13879. */
  13880. getPivotPoint(): Vector3;
  13881. /**
  13882. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13883. * @param result the vector3 to store the result
  13884. * @returns this TransformNode.
  13885. */
  13886. getPivotPointToRef(result: Vector3): TransformNode;
  13887. /**
  13888. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13889. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13890. */
  13891. getAbsolutePivotPoint(): Vector3;
  13892. /**
  13893. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13894. * @param result vector3 to store the result
  13895. * @returns this TransformNode.
  13896. */
  13897. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13898. /**
  13899. * Defines the passed node as the parent of the current node.
  13900. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13901. * @see https://doc.babylonjs.com/how_to/parenting
  13902. * @param node the node ot set as the parent
  13903. * @returns this TransformNode.
  13904. */
  13905. setParent(node: Nullable<Node>): TransformNode;
  13906. private _nonUniformScaling;
  13907. /**
  13908. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13909. */
  13910. get nonUniformScaling(): boolean;
  13911. /** @hidden */
  13912. _updateNonUniformScalingState(value: boolean): boolean;
  13913. /**
  13914. * Attach the current TransformNode to another TransformNode associated with a bone
  13915. * @param bone Bone affecting the TransformNode
  13916. * @param affectedTransformNode TransformNode associated with the bone
  13917. * @returns this object
  13918. */
  13919. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13920. /**
  13921. * Detach the transform node if its associated with a bone
  13922. * @returns this object
  13923. */
  13924. detachFromBone(): TransformNode;
  13925. private static _rotationAxisCache;
  13926. /**
  13927. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13928. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13929. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13930. * The passed axis is also normalized.
  13931. * @param axis the axis to rotate around
  13932. * @param amount the amount to rotate in radians
  13933. * @param space Space to rotate in (Default: local)
  13934. * @returns the TransformNode.
  13935. */
  13936. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13937. /**
  13938. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13939. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13940. * The passed axis is also normalized. .
  13941. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13942. * @param point the point to rotate around
  13943. * @param axis the axis to rotate around
  13944. * @param amount the amount to rotate in radians
  13945. * @returns the TransformNode
  13946. */
  13947. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13948. /**
  13949. * Translates the mesh along the axis vector for the passed distance in the given space.
  13950. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13951. * @param axis the axis to translate in
  13952. * @param distance the distance to translate
  13953. * @param space Space to rotate in (Default: local)
  13954. * @returns the TransformNode.
  13955. */
  13956. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13957. /**
  13958. * Adds a rotation step to the mesh current rotation.
  13959. * x, y, z are Euler angles expressed in radians.
  13960. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13961. * This means this rotation is made in the mesh local space only.
  13962. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13963. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13964. * ```javascript
  13965. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13966. * ```
  13967. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13968. * 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.
  13969. * @param x Rotation to add
  13970. * @param y Rotation to add
  13971. * @param z Rotation to add
  13972. * @returns the TransformNode.
  13973. */
  13974. addRotation(x: number, y: number, z: number): TransformNode;
  13975. /**
  13976. * @hidden
  13977. */
  13978. protected _getEffectiveParent(): Nullable<Node>;
  13979. /**
  13980. * Computes the world matrix of the node
  13981. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13982. * @returns the world matrix
  13983. */
  13984. computeWorldMatrix(force?: boolean): Matrix;
  13985. /**
  13986. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13987. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13988. */
  13989. resetLocalMatrix(independentOfChildren?: boolean): void;
  13990. protected _afterComputeWorldMatrix(): void;
  13991. /**
  13992. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13993. * @param func callback function to add
  13994. *
  13995. * @returns the TransformNode.
  13996. */
  13997. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13998. /**
  13999. * Removes a registered callback function.
  14000. * @param func callback function to remove
  14001. * @returns the TransformNode.
  14002. */
  14003. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14004. /**
  14005. * Gets the position of the current mesh in camera space
  14006. * @param camera defines the camera to use
  14007. * @returns a position
  14008. */
  14009. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14010. /**
  14011. * Returns the distance from the mesh to the active camera
  14012. * @param camera defines the camera to use
  14013. * @returns the distance
  14014. */
  14015. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14016. /**
  14017. * Clone the current transform node
  14018. * @param name Name of the new clone
  14019. * @param newParent New parent for the clone
  14020. * @param doNotCloneChildren Do not clone children hierarchy
  14021. * @returns the new transform node
  14022. */
  14023. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14024. /**
  14025. * Serializes the objects information.
  14026. * @param currentSerializationObject defines the object to serialize in
  14027. * @returns the serialized object
  14028. */
  14029. serialize(currentSerializationObject?: any): any;
  14030. /**
  14031. * Returns a new TransformNode object parsed from the source provided.
  14032. * @param parsedTransformNode is the source.
  14033. * @param scene the scne the object belongs to
  14034. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14035. * @returns a new TransformNode object parsed from the source provided.
  14036. */
  14037. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14038. /**
  14039. * Get all child-transformNodes of this node
  14040. * @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
  14041. * @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
  14042. * @returns an array of TransformNode
  14043. */
  14044. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14045. /**
  14046. * Releases resources associated with this transform node.
  14047. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14048. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14049. */
  14050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14051. /**
  14052. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14053. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14054. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14055. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14056. * @returns the current mesh
  14057. */
  14058. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14059. private _syncAbsoluteScalingAndRotation;
  14060. }
  14061. }
  14062. declare module BABYLON {
  14063. /**
  14064. * Class used to override all child animations of a given target
  14065. */
  14066. export class AnimationPropertiesOverride {
  14067. /**
  14068. * Gets or sets a value indicating if animation blending must be used
  14069. */
  14070. enableBlending: boolean;
  14071. /**
  14072. * Gets or sets the blending speed to use when enableBlending is true
  14073. */
  14074. blendingSpeed: number;
  14075. /**
  14076. * Gets or sets the default loop mode to use
  14077. */
  14078. loopMode: number;
  14079. }
  14080. }
  14081. declare module BABYLON {
  14082. /**
  14083. * Class used to store bone information
  14084. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14085. */
  14086. export class Bone extends Node {
  14087. /**
  14088. * defines the bone name
  14089. */
  14090. name: string;
  14091. private static _tmpVecs;
  14092. private static _tmpQuat;
  14093. private static _tmpMats;
  14094. /**
  14095. * Gets the list of child bones
  14096. */
  14097. children: Bone[];
  14098. /** Gets the animations associated with this bone */
  14099. animations: Animation[];
  14100. /**
  14101. * Gets or sets bone length
  14102. */
  14103. length: number;
  14104. /**
  14105. * @hidden Internal only
  14106. * Set this value to map this bone to a different index in the transform matrices
  14107. * Set this value to -1 to exclude the bone from the transform matrices
  14108. */
  14109. _index: Nullable<number>;
  14110. private _skeleton;
  14111. private _localMatrix;
  14112. private _restPose;
  14113. private _baseMatrix;
  14114. private _absoluteTransform;
  14115. private _invertedAbsoluteTransform;
  14116. private _parent;
  14117. private _scalingDeterminant;
  14118. private _worldTransform;
  14119. private _localScaling;
  14120. private _localRotation;
  14121. private _localPosition;
  14122. private _needToDecompose;
  14123. private _needToCompose;
  14124. /** @hidden */
  14125. _linkedTransformNode: Nullable<TransformNode>;
  14126. /** @hidden */
  14127. _waitingTransformNodeId: Nullable<string>;
  14128. /** @hidden */
  14129. get _matrix(): Matrix;
  14130. /** @hidden */
  14131. set _matrix(value: Matrix);
  14132. /**
  14133. * Create a new bone
  14134. * @param name defines the bone name
  14135. * @param skeleton defines the parent skeleton
  14136. * @param parentBone defines the parent (can be null if the bone is the root)
  14137. * @param localMatrix defines the local matrix
  14138. * @param restPose defines the rest pose matrix
  14139. * @param baseMatrix defines the base matrix
  14140. * @param index defines index of the bone in the hiearchy
  14141. */
  14142. constructor(
  14143. /**
  14144. * defines the bone name
  14145. */
  14146. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14147. /**
  14148. * Gets the current object class name.
  14149. * @return the class name
  14150. */
  14151. getClassName(): string;
  14152. /**
  14153. * Gets the parent skeleton
  14154. * @returns a skeleton
  14155. */
  14156. getSkeleton(): Skeleton;
  14157. /**
  14158. * Gets parent bone
  14159. * @returns a bone or null if the bone is the root of the bone hierarchy
  14160. */
  14161. getParent(): Nullable<Bone>;
  14162. /**
  14163. * Returns an array containing the root bones
  14164. * @returns an array containing the root bones
  14165. */
  14166. getChildren(): Array<Bone>;
  14167. /**
  14168. * Gets the node index in matrix array generated for rendering
  14169. * @returns the node index
  14170. */
  14171. getIndex(): number;
  14172. /**
  14173. * Sets the parent bone
  14174. * @param parent defines the parent (can be null if the bone is the root)
  14175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14176. */
  14177. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14178. /**
  14179. * Gets the local matrix
  14180. * @returns a matrix
  14181. */
  14182. getLocalMatrix(): Matrix;
  14183. /**
  14184. * Gets the base matrix (initial matrix which remains unchanged)
  14185. * @returns a matrix
  14186. */
  14187. getBaseMatrix(): Matrix;
  14188. /**
  14189. * Gets the rest pose matrix
  14190. * @returns a matrix
  14191. */
  14192. getRestPose(): Matrix;
  14193. /**
  14194. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14195. */
  14196. getWorldMatrix(): Matrix;
  14197. /**
  14198. * Sets the local matrix to rest pose matrix
  14199. */
  14200. returnToRest(): void;
  14201. /**
  14202. * Gets the inverse of the absolute transform matrix.
  14203. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14204. * @returns a matrix
  14205. */
  14206. getInvertedAbsoluteTransform(): Matrix;
  14207. /**
  14208. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14209. * @returns a matrix
  14210. */
  14211. getAbsoluteTransform(): Matrix;
  14212. /**
  14213. * Links with the given transform node.
  14214. * The local matrix of this bone is copied from the transform node every frame.
  14215. * @param transformNode defines the transform node to link to
  14216. */
  14217. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14218. /**
  14219. * Gets the node used to drive the bone's transformation
  14220. * @returns a transform node or null
  14221. */
  14222. getTransformNode(): Nullable<TransformNode>;
  14223. /** Gets or sets current position (in local space) */
  14224. get position(): Vector3;
  14225. set position(newPosition: Vector3);
  14226. /** Gets or sets current rotation (in local space) */
  14227. get rotation(): Vector3;
  14228. set rotation(newRotation: Vector3);
  14229. /** Gets or sets current rotation quaternion (in local space) */
  14230. get rotationQuaternion(): Quaternion;
  14231. set rotationQuaternion(newRotation: Quaternion);
  14232. /** Gets or sets current scaling (in local space) */
  14233. get scaling(): Vector3;
  14234. set scaling(newScaling: Vector3);
  14235. /**
  14236. * Gets the animation properties override
  14237. */
  14238. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14239. private _decompose;
  14240. private _compose;
  14241. /**
  14242. * Update the base and local matrices
  14243. * @param matrix defines the new base or local matrix
  14244. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14245. * @param updateLocalMatrix defines if the local matrix should be updated
  14246. */
  14247. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14248. /** @hidden */
  14249. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14250. /**
  14251. * Flag the bone as dirty (Forcing it to update everything)
  14252. */
  14253. markAsDirty(): void;
  14254. /** @hidden */
  14255. _markAsDirtyAndCompose(): void;
  14256. private _markAsDirtyAndDecompose;
  14257. /**
  14258. * Translate the bone in local or world space
  14259. * @param vec The amount to translate the bone
  14260. * @param space The space that the translation is in
  14261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14262. */
  14263. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14264. /**
  14265. * Set the postion of the bone in local or world space
  14266. * @param position The position to set the bone
  14267. * @param space The space that the position is in
  14268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14269. */
  14270. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14271. /**
  14272. * Set the absolute position of the bone (world space)
  14273. * @param position The position to set the bone
  14274. * @param mesh The mesh that this bone is attached to
  14275. */
  14276. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14277. /**
  14278. * Scale the bone on the x, y and z axes (in local space)
  14279. * @param x The amount to scale the bone on the x axis
  14280. * @param y The amount to scale the bone on the y axis
  14281. * @param z The amount to scale the bone on the z axis
  14282. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14283. */
  14284. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14285. /**
  14286. * Set the bone scaling in local space
  14287. * @param scale defines the scaling vector
  14288. */
  14289. setScale(scale: Vector3): void;
  14290. /**
  14291. * Gets the current scaling in local space
  14292. * @returns the current scaling vector
  14293. */
  14294. getScale(): Vector3;
  14295. /**
  14296. * Gets the current scaling in local space and stores it in a target vector
  14297. * @param result defines the target vector
  14298. */
  14299. getScaleToRef(result: Vector3): void;
  14300. /**
  14301. * Set the yaw, pitch, and roll of the bone in local or world space
  14302. * @param yaw The rotation of the bone on the y axis
  14303. * @param pitch The rotation of the bone on the x axis
  14304. * @param roll The rotation of the bone on the z axis
  14305. * @param space The space that the axes of rotation are in
  14306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14307. */
  14308. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14309. /**
  14310. * Add a rotation to the bone on an axis in local or world space
  14311. * @param axis The axis to rotate the bone on
  14312. * @param amount The amount to rotate the bone
  14313. * @param space The space that the axis is in
  14314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14315. */
  14316. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14317. /**
  14318. * Set the rotation of the bone to a particular axis angle in local or world space
  14319. * @param axis The axis to rotate the bone on
  14320. * @param angle The angle that the bone should be rotated to
  14321. * @param space The space that the axis is in
  14322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14323. */
  14324. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14325. /**
  14326. * Set the euler rotation of the bone in local of world space
  14327. * @param rotation The euler rotation that the bone should be set to
  14328. * @param space The space that the rotation is in
  14329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14330. */
  14331. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14332. /**
  14333. * Set the quaternion rotation of the bone in local of world space
  14334. * @param quat The quaternion rotation that the bone should be set to
  14335. * @param space The space that the rotation is in
  14336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14337. */
  14338. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14339. /**
  14340. * Set the rotation matrix of the bone in local of world space
  14341. * @param rotMat The rotation matrix that the bone should be set to
  14342. * @param space The space that the rotation is in
  14343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14344. */
  14345. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14346. private _rotateWithMatrix;
  14347. private _getNegativeRotationToRef;
  14348. /**
  14349. * Get the position of the bone in local or world space
  14350. * @param space The space that the returned position is in
  14351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14352. * @returns The position of the bone
  14353. */
  14354. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14355. /**
  14356. * Copy the position of the bone to a vector3 in local or world space
  14357. * @param space The space that the returned position is in
  14358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14359. * @param result The vector3 to copy the position to
  14360. */
  14361. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14362. /**
  14363. * Get the absolute position of the bone (world space)
  14364. * @param mesh The mesh that this bone is attached to
  14365. * @returns The absolute position of the bone
  14366. */
  14367. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14368. /**
  14369. * Copy the absolute position of the bone (world space) to the result param
  14370. * @param mesh The mesh that this bone is attached to
  14371. * @param result The vector3 to copy the absolute position to
  14372. */
  14373. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14374. /**
  14375. * Compute the absolute transforms of this bone and its children
  14376. */
  14377. computeAbsoluteTransforms(): void;
  14378. /**
  14379. * Get the world direction from an axis that is in the local space of the bone
  14380. * @param localAxis The local direction that is used to compute the world direction
  14381. * @param mesh The mesh that this bone is attached to
  14382. * @returns The world direction
  14383. */
  14384. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14385. /**
  14386. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14387. * @param localAxis The local direction that is used to compute the world direction
  14388. * @param mesh The mesh that this bone is attached to
  14389. * @param result The vector3 that the world direction will be copied to
  14390. */
  14391. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14392. /**
  14393. * Get the euler rotation of the bone in local or world space
  14394. * @param space The space that the rotation should be in
  14395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14396. * @returns The euler rotation
  14397. */
  14398. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14399. /**
  14400. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14401. * @param space The space that the rotation should be in
  14402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14403. * @param result The vector3 that the rotation should be copied to
  14404. */
  14405. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14406. /**
  14407. * Get the quaternion rotation of the bone in either local or world space
  14408. * @param space The space that the rotation should be in
  14409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14410. * @returns The quaternion rotation
  14411. */
  14412. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14413. /**
  14414. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14415. * @param space The space that the rotation should be in
  14416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14417. * @param result The quaternion that the rotation should be copied to
  14418. */
  14419. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14420. /**
  14421. * Get the rotation matrix of the bone in local or world space
  14422. * @param space The space that the rotation should be in
  14423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14424. * @returns The rotation matrix
  14425. */
  14426. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14427. /**
  14428. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14429. * @param space The space that the rotation should be in
  14430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14431. * @param result The quaternion that the rotation should be copied to
  14432. */
  14433. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14434. /**
  14435. * Get the world position of a point that is in the local space of the bone
  14436. * @param position The local position
  14437. * @param mesh The mesh that this bone is attached to
  14438. * @returns The world position
  14439. */
  14440. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14441. /**
  14442. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14443. * @param position The local position
  14444. * @param mesh The mesh that this bone is attached to
  14445. * @param result The vector3 that the world position should be copied to
  14446. */
  14447. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14448. /**
  14449. * Get the local position of a point that is in world space
  14450. * @param position The world position
  14451. * @param mesh The mesh that this bone is attached to
  14452. * @returns The local position
  14453. */
  14454. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14455. /**
  14456. * Get the local position of a point that is in world space and copy it to the result param
  14457. * @param position The world position
  14458. * @param mesh The mesh that this bone is attached to
  14459. * @param result The vector3 that the local position should be copied to
  14460. */
  14461. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14462. }
  14463. }
  14464. declare module BABYLON {
  14465. /**
  14466. * Defines a runtime animation
  14467. */
  14468. export class RuntimeAnimation {
  14469. private _events;
  14470. /**
  14471. * The current frame of the runtime animation
  14472. */
  14473. private _currentFrame;
  14474. /**
  14475. * The animation used by the runtime animation
  14476. */
  14477. private _animation;
  14478. /**
  14479. * The target of the runtime animation
  14480. */
  14481. private _target;
  14482. /**
  14483. * The initiating animatable
  14484. */
  14485. private _host;
  14486. /**
  14487. * The original value of the runtime animation
  14488. */
  14489. private _originalValue;
  14490. /**
  14491. * The original blend value of the runtime animation
  14492. */
  14493. private _originalBlendValue;
  14494. /**
  14495. * The offsets cache of the runtime animation
  14496. */
  14497. private _offsetsCache;
  14498. /**
  14499. * The high limits cache of the runtime animation
  14500. */
  14501. private _highLimitsCache;
  14502. /**
  14503. * Specifies if the runtime animation has been stopped
  14504. */
  14505. private _stopped;
  14506. /**
  14507. * The blending factor of the runtime animation
  14508. */
  14509. private _blendingFactor;
  14510. /**
  14511. * The BabylonJS scene
  14512. */
  14513. private _scene;
  14514. /**
  14515. * The current value of the runtime animation
  14516. */
  14517. private _currentValue;
  14518. /** @hidden */
  14519. _animationState: _IAnimationState;
  14520. /**
  14521. * The active target of the runtime animation
  14522. */
  14523. private _activeTargets;
  14524. private _currentActiveTarget;
  14525. private _directTarget;
  14526. /**
  14527. * The target path of the runtime animation
  14528. */
  14529. private _targetPath;
  14530. /**
  14531. * The weight of the runtime animation
  14532. */
  14533. private _weight;
  14534. /**
  14535. * The ratio offset of the runtime animation
  14536. */
  14537. private _ratioOffset;
  14538. /**
  14539. * The previous delay of the runtime animation
  14540. */
  14541. private _previousDelay;
  14542. /**
  14543. * The previous ratio of the runtime animation
  14544. */
  14545. private _previousRatio;
  14546. private _enableBlending;
  14547. private _keys;
  14548. private _minFrame;
  14549. private _maxFrame;
  14550. private _minValue;
  14551. private _maxValue;
  14552. private _targetIsArray;
  14553. /**
  14554. * Gets the current frame of the runtime animation
  14555. */
  14556. get currentFrame(): number;
  14557. /**
  14558. * Gets the weight of the runtime animation
  14559. */
  14560. get weight(): number;
  14561. /**
  14562. * Gets the current value of the runtime animation
  14563. */
  14564. get currentValue(): any;
  14565. /**
  14566. * Gets the target path of the runtime animation
  14567. */
  14568. get targetPath(): string;
  14569. /**
  14570. * Gets the actual target of the runtime animation
  14571. */
  14572. get target(): any;
  14573. /**
  14574. * Gets the additive state of the runtime animation
  14575. */
  14576. get isAdditive(): boolean;
  14577. /** @hidden */
  14578. _onLoop: () => void;
  14579. /**
  14580. * Create a new RuntimeAnimation object
  14581. * @param target defines the target of the animation
  14582. * @param animation defines the source animation object
  14583. * @param scene defines the hosting scene
  14584. * @param host defines the initiating Animatable
  14585. */
  14586. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14587. private _preparePath;
  14588. /**
  14589. * Gets the animation from the runtime animation
  14590. */
  14591. get animation(): Animation;
  14592. /**
  14593. * Resets the runtime animation to the beginning
  14594. * @param restoreOriginal defines whether to restore the target property to the original value
  14595. */
  14596. reset(restoreOriginal?: boolean): void;
  14597. /**
  14598. * Specifies if the runtime animation is stopped
  14599. * @returns Boolean specifying if the runtime animation is stopped
  14600. */
  14601. isStopped(): boolean;
  14602. /**
  14603. * Disposes of the runtime animation
  14604. */
  14605. dispose(): void;
  14606. /**
  14607. * Apply the interpolated value to the target
  14608. * @param currentValue defines the value computed by the animation
  14609. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14610. */
  14611. setValue(currentValue: any, weight: number): void;
  14612. private _getOriginalValues;
  14613. private _setValue;
  14614. /**
  14615. * Gets the loop pmode of the runtime animation
  14616. * @returns Loop Mode
  14617. */
  14618. private _getCorrectLoopMode;
  14619. /**
  14620. * Move the current animation to a given frame
  14621. * @param frame defines the frame to move to
  14622. */
  14623. goToFrame(frame: number): void;
  14624. /**
  14625. * @hidden Internal use only
  14626. */
  14627. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14628. /**
  14629. * Execute the current animation
  14630. * @param delay defines the delay to add to the current frame
  14631. * @param from defines the lower bound of the animation range
  14632. * @param to defines the upper bound of the animation range
  14633. * @param loop defines if the current animation must loop
  14634. * @param speedRatio defines the current speed ratio
  14635. * @param weight defines the weight of the animation (default is -1 so no weight)
  14636. * @param onLoop optional callback called when animation loops
  14637. * @returns a boolean indicating if the animation is running
  14638. */
  14639. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14640. }
  14641. }
  14642. declare module BABYLON {
  14643. /**
  14644. * Class used to store an actual running animation
  14645. */
  14646. export class Animatable {
  14647. /** defines the target object */
  14648. target: any;
  14649. /** defines the starting frame number (default is 0) */
  14650. fromFrame: number;
  14651. /** defines the ending frame number (default is 100) */
  14652. toFrame: number;
  14653. /** defines if the animation must loop (default is false) */
  14654. loopAnimation: boolean;
  14655. /** defines a callback to call when animation ends if it is not looping */
  14656. onAnimationEnd?: (() => void) | null | undefined;
  14657. /** defines a callback to call when animation loops */
  14658. onAnimationLoop?: (() => void) | null | undefined;
  14659. /** defines whether the animation should be evaluated additively */
  14660. isAdditive: boolean;
  14661. private _localDelayOffset;
  14662. private _pausedDelay;
  14663. private _runtimeAnimations;
  14664. private _paused;
  14665. private _scene;
  14666. private _speedRatio;
  14667. private _weight;
  14668. private _syncRoot;
  14669. /**
  14670. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14671. * This will only apply for non looping animation (default is true)
  14672. */
  14673. disposeOnEnd: boolean;
  14674. /**
  14675. * Gets a boolean indicating if the animation has started
  14676. */
  14677. animationStarted: boolean;
  14678. /**
  14679. * Observer raised when the animation ends
  14680. */
  14681. onAnimationEndObservable: Observable<Animatable>;
  14682. /**
  14683. * Observer raised when the animation loops
  14684. */
  14685. onAnimationLoopObservable: Observable<Animatable>;
  14686. /**
  14687. * Gets the root Animatable used to synchronize and normalize animations
  14688. */
  14689. get syncRoot(): Nullable<Animatable>;
  14690. /**
  14691. * Gets the current frame of the first RuntimeAnimation
  14692. * Used to synchronize Animatables
  14693. */
  14694. get masterFrame(): number;
  14695. /**
  14696. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14697. */
  14698. get weight(): number;
  14699. set weight(value: number);
  14700. /**
  14701. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14702. */
  14703. get speedRatio(): number;
  14704. set speedRatio(value: number);
  14705. /**
  14706. * Creates a new Animatable
  14707. * @param scene defines the hosting scene
  14708. * @param target defines the target object
  14709. * @param fromFrame defines the starting frame number (default is 0)
  14710. * @param toFrame defines the ending frame number (default is 100)
  14711. * @param loopAnimation defines if the animation must loop (default is false)
  14712. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14713. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14714. * @param animations defines a group of animation to add to the new Animatable
  14715. * @param onAnimationLoop defines a callback to call when animation loops
  14716. * @param isAdditive defines whether the animation should be evaluated additively
  14717. */
  14718. constructor(scene: Scene,
  14719. /** defines the target object */
  14720. target: any,
  14721. /** defines the starting frame number (default is 0) */
  14722. fromFrame?: number,
  14723. /** defines the ending frame number (default is 100) */
  14724. toFrame?: number,
  14725. /** defines if the animation must loop (default is false) */
  14726. loopAnimation?: boolean, speedRatio?: number,
  14727. /** defines a callback to call when animation ends if it is not looping */
  14728. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14729. /** defines a callback to call when animation loops */
  14730. onAnimationLoop?: (() => void) | null | undefined,
  14731. /** defines whether the animation should be evaluated additively */
  14732. isAdditive?: boolean);
  14733. /**
  14734. * Synchronize and normalize current Animatable with a source Animatable
  14735. * This is useful when using animation weights and when animations are not of the same length
  14736. * @param root defines the root Animatable to synchronize with
  14737. * @returns the current Animatable
  14738. */
  14739. syncWith(root: Animatable): Animatable;
  14740. /**
  14741. * Gets the list of runtime animations
  14742. * @returns an array of RuntimeAnimation
  14743. */
  14744. getAnimations(): RuntimeAnimation[];
  14745. /**
  14746. * Adds more animations to the current animatable
  14747. * @param target defines the target of the animations
  14748. * @param animations defines the new animations to add
  14749. */
  14750. appendAnimations(target: any, animations: Animation[]): void;
  14751. /**
  14752. * Gets the source animation for a specific property
  14753. * @param property defines the propertyu to look for
  14754. * @returns null or the source animation for the given property
  14755. */
  14756. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14757. /**
  14758. * Gets the runtime animation for a specific property
  14759. * @param property defines the propertyu to look for
  14760. * @returns null or the runtime animation for the given property
  14761. */
  14762. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14763. /**
  14764. * Resets the animatable to its original state
  14765. */
  14766. reset(): void;
  14767. /**
  14768. * Allows the animatable to blend with current running animations
  14769. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14770. * @param blendingSpeed defines the blending speed to use
  14771. */
  14772. enableBlending(blendingSpeed: number): void;
  14773. /**
  14774. * Disable animation blending
  14775. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14776. */
  14777. disableBlending(): void;
  14778. /**
  14779. * Jump directly to a given frame
  14780. * @param frame defines the frame to jump to
  14781. */
  14782. goToFrame(frame: number): void;
  14783. /**
  14784. * Pause the animation
  14785. */
  14786. pause(): void;
  14787. /**
  14788. * Restart the animation
  14789. */
  14790. restart(): void;
  14791. private _raiseOnAnimationEnd;
  14792. /**
  14793. * Stop and delete the current animation
  14794. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14795. * @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)
  14796. */
  14797. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14798. /**
  14799. * Wait asynchronously for the animation to end
  14800. * @returns a promise which will be fullfilled when the animation ends
  14801. */
  14802. waitAsync(): Promise<Animatable>;
  14803. /** @hidden */
  14804. _animate(delay: number): boolean;
  14805. }
  14806. interface Scene {
  14807. /** @hidden */
  14808. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14809. /** @hidden */
  14810. _processLateAnimationBindingsForMatrices(holder: {
  14811. totalWeight: number;
  14812. totalAdditiveWeight: number;
  14813. animations: RuntimeAnimation[];
  14814. additiveAnimations: RuntimeAnimation[];
  14815. originalValue: Matrix;
  14816. }): any;
  14817. /** @hidden */
  14818. _processLateAnimationBindingsForQuaternions(holder: {
  14819. totalWeight: number;
  14820. totalAdditiveWeight: number;
  14821. animations: RuntimeAnimation[];
  14822. additiveAnimations: RuntimeAnimation[];
  14823. originalValue: Quaternion;
  14824. }, refQuaternion: Quaternion): Quaternion;
  14825. /** @hidden */
  14826. _processLateAnimationBindings(): void;
  14827. /**
  14828. * Will start the animation sequence of a given target
  14829. * @param target defines the target
  14830. * @param from defines from which frame should animation start
  14831. * @param to defines until which frame should animation run.
  14832. * @param weight defines the weight to apply to the animation (1.0 by default)
  14833. * @param loop defines if the animation loops
  14834. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14835. * @param onAnimationEnd defines the function to be executed when the animation ends
  14836. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14837. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14838. * @param onAnimationLoop defines the callback to call when an animation loops
  14839. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14840. * @returns the animatable object created for this animation
  14841. */
  14842. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14843. /**
  14844. * Will start the animation sequence of a given target
  14845. * @param target defines the target
  14846. * @param from defines from which frame should animation start
  14847. * @param to defines until which frame should animation run.
  14848. * @param loop defines if the animation loops
  14849. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14850. * @param onAnimationEnd defines the function to be executed when the animation ends
  14851. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14852. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14853. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14854. * @param onAnimationLoop defines the callback to call when an animation loops
  14855. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14856. * @returns the animatable object created for this animation
  14857. */
  14858. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14859. /**
  14860. * Will start the animation sequence of a given target and its hierarchy
  14861. * @param target defines the target
  14862. * @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.
  14863. * @param from defines from which frame should animation start
  14864. * @param to defines until which frame should animation run.
  14865. * @param loop defines if the animation loops
  14866. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14867. * @param onAnimationEnd defines the function to be executed when the animation ends
  14868. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14869. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14870. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14871. * @param onAnimationLoop defines the callback to call when an animation loops
  14872. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14873. * @returns the list of created animatables
  14874. */
  14875. 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, isAdditive?: boolean): Animatable[];
  14876. /**
  14877. * Begin a new animation on a given node
  14878. * @param target defines the target where the animation will take place
  14879. * @param animations defines the list of animations to start
  14880. * @param from defines the initial value
  14881. * @param to defines the final value
  14882. * @param loop defines if you want animation to loop (off by default)
  14883. * @param speedRatio defines the speed ratio to apply to all animations
  14884. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14885. * @param onAnimationLoop defines the callback to call when an animation loops
  14886. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14887. * @returns the list of created animatables
  14888. */
  14889. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14890. /**
  14891. * Begin a new animation on a given node and its hierarchy
  14892. * @param target defines the root node where the animation will take place
  14893. * @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.
  14894. * @param animations defines the list of animations to start
  14895. * @param from defines the initial value
  14896. * @param to defines the final value
  14897. * @param loop defines if you want animation to loop (off by default)
  14898. * @param speedRatio defines the speed ratio to apply to all animations
  14899. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14900. * @param onAnimationLoop defines the callback to call when an animation loops
  14901. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14902. * @returns the list of animatables created for all nodes
  14903. */
  14904. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14905. /**
  14906. * Gets the animatable associated with a specific target
  14907. * @param target defines the target of the animatable
  14908. * @returns the required animatable if found
  14909. */
  14910. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14911. /**
  14912. * Gets all animatables associated with a given target
  14913. * @param target defines the target to look animatables for
  14914. * @returns an array of Animatables
  14915. */
  14916. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14917. /**
  14918. * Stops and removes all animations that have been applied to the scene
  14919. */
  14920. stopAllAnimations(): void;
  14921. /**
  14922. * Gets the current delta time used by animation engine
  14923. */
  14924. deltaTime: number;
  14925. }
  14926. interface Bone {
  14927. /**
  14928. * Copy an animation range from another bone
  14929. * @param source defines the source bone
  14930. * @param rangeName defines the range name to copy
  14931. * @param frameOffset defines the frame offset
  14932. * @param rescaleAsRequired defines if rescaling must be applied if required
  14933. * @param skelDimensionsRatio defines the scaling ratio
  14934. * @returns true if operation was successful
  14935. */
  14936. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14937. }
  14938. }
  14939. declare module BABYLON {
  14940. /**
  14941. * Class used to handle skinning animations
  14942. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14943. */
  14944. export class Skeleton implements IAnimatable {
  14945. /** defines the skeleton name */
  14946. name: string;
  14947. /** defines the skeleton Id */
  14948. id: string;
  14949. /**
  14950. * Defines the list of child bones
  14951. */
  14952. bones: Bone[];
  14953. /**
  14954. * Defines an estimate of the dimension of the skeleton at rest
  14955. */
  14956. dimensionsAtRest: Vector3;
  14957. /**
  14958. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14959. */
  14960. needInitialSkinMatrix: boolean;
  14961. /**
  14962. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14963. */
  14964. overrideMesh: Nullable<AbstractMesh>;
  14965. /**
  14966. * Gets the list of animations attached to this skeleton
  14967. */
  14968. animations: Array<Animation>;
  14969. private _scene;
  14970. private _isDirty;
  14971. private _transformMatrices;
  14972. private _transformMatrixTexture;
  14973. private _meshesWithPoseMatrix;
  14974. private _animatables;
  14975. private _identity;
  14976. private _synchronizedWithMesh;
  14977. private _ranges;
  14978. private _lastAbsoluteTransformsUpdateId;
  14979. private _canUseTextureForBones;
  14980. private _uniqueId;
  14981. /** @hidden */
  14982. _numBonesWithLinkedTransformNode: number;
  14983. /** @hidden */
  14984. _hasWaitingData: Nullable<boolean>;
  14985. /**
  14986. * Specifies if the skeleton should be serialized
  14987. */
  14988. doNotSerialize: boolean;
  14989. private _useTextureToStoreBoneMatrices;
  14990. /**
  14991. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14992. * Please note that this option is not available if the hardware does not support it
  14993. */
  14994. get useTextureToStoreBoneMatrices(): boolean;
  14995. set useTextureToStoreBoneMatrices(value: boolean);
  14996. private _animationPropertiesOverride;
  14997. /**
  14998. * Gets or sets the animation properties override
  14999. */
  15000. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15001. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15002. /**
  15003. * List of inspectable custom properties (used by the Inspector)
  15004. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15005. */
  15006. inspectableCustomProperties: IInspectable[];
  15007. /**
  15008. * An observable triggered before computing the skeleton's matrices
  15009. */
  15010. onBeforeComputeObservable: Observable<Skeleton>;
  15011. /**
  15012. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15013. */
  15014. get isUsingTextureForMatrices(): boolean;
  15015. /**
  15016. * Gets the unique ID of this skeleton
  15017. */
  15018. get uniqueId(): number;
  15019. /**
  15020. * Creates a new skeleton
  15021. * @param name defines the skeleton name
  15022. * @param id defines the skeleton Id
  15023. * @param scene defines the hosting scene
  15024. */
  15025. constructor(
  15026. /** defines the skeleton name */
  15027. name: string,
  15028. /** defines the skeleton Id */
  15029. id: string, scene: Scene);
  15030. /**
  15031. * Gets the current object class name.
  15032. * @return the class name
  15033. */
  15034. getClassName(): string;
  15035. /**
  15036. * Returns an array containing the root bones
  15037. * @returns an array containing the root bones
  15038. */
  15039. getChildren(): Array<Bone>;
  15040. /**
  15041. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15042. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15043. * @returns a Float32Array containing matrices data
  15044. */
  15045. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15046. /**
  15047. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15048. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15049. * @returns a raw texture containing the data
  15050. */
  15051. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15052. /**
  15053. * Gets the current hosting scene
  15054. * @returns a scene object
  15055. */
  15056. getScene(): Scene;
  15057. /**
  15058. * Gets a string representing the current skeleton data
  15059. * @param fullDetails defines a boolean indicating if we want a verbose version
  15060. * @returns a string representing the current skeleton data
  15061. */
  15062. toString(fullDetails?: boolean): string;
  15063. /**
  15064. * Get bone's index searching by name
  15065. * @param name defines bone's name to search for
  15066. * @return the indice of the bone. Returns -1 if not found
  15067. */
  15068. getBoneIndexByName(name: string): number;
  15069. /**
  15070. * Creater a new animation range
  15071. * @param name defines the name of the range
  15072. * @param from defines the start key
  15073. * @param to defines the end key
  15074. */
  15075. createAnimationRange(name: string, from: number, to: number): void;
  15076. /**
  15077. * Delete a specific animation range
  15078. * @param name defines the name of the range
  15079. * @param deleteFrames defines if frames must be removed as well
  15080. */
  15081. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15082. /**
  15083. * Gets a specific animation range
  15084. * @param name defines the name of the range to look for
  15085. * @returns the requested animation range or null if not found
  15086. */
  15087. getAnimationRange(name: string): Nullable<AnimationRange>;
  15088. /**
  15089. * Gets the list of all animation ranges defined on this skeleton
  15090. * @returns an array
  15091. */
  15092. getAnimationRanges(): Nullable<AnimationRange>[];
  15093. /**
  15094. * Copy animation range from a source skeleton.
  15095. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15096. * @param source defines the source skeleton
  15097. * @param name defines the name of the range to copy
  15098. * @param rescaleAsRequired defines if rescaling must be applied if required
  15099. * @returns true if operation was successful
  15100. */
  15101. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15102. /**
  15103. * Forces the skeleton to go to rest pose
  15104. */
  15105. returnToRest(): void;
  15106. private _getHighestAnimationFrame;
  15107. /**
  15108. * Begin a specific animation range
  15109. * @param name defines the name of the range to start
  15110. * @param loop defines if looping must be turned on (false by default)
  15111. * @param speedRatio defines the speed ratio to apply (1 by default)
  15112. * @param onAnimationEnd defines a callback which will be called when animation will end
  15113. * @returns a new animatable
  15114. */
  15115. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15116. /**
  15117. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15118. * @param skeleton defines the Skeleton containing the animation range to convert
  15119. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15120. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15121. * @returns the original skeleton
  15122. */
  15123. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15124. /** @hidden */
  15125. _markAsDirty(): void;
  15126. /** @hidden */
  15127. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15128. /** @hidden */
  15129. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15130. private _computeTransformMatrices;
  15131. /**
  15132. * Build all resources required to render a skeleton
  15133. */
  15134. prepare(): void;
  15135. /**
  15136. * Gets the list of animatables currently running for this skeleton
  15137. * @returns an array of animatables
  15138. */
  15139. getAnimatables(): IAnimatable[];
  15140. /**
  15141. * Clone the current skeleton
  15142. * @param name defines the name of the new skeleton
  15143. * @param id defines the id of the new skeleton
  15144. * @returns the new skeleton
  15145. */
  15146. clone(name: string, id?: string): Skeleton;
  15147. /**
  15148. * Enable animation blending for this skeleton
  15149. * @param blendingSpeed defines the blending speed to apply
  15150. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15151. */
  15152. enableBlending(blendingSpeed?: number): void;
  15153. /**
  15154. * Releases all resources associated with the current skeleton
  15155. */
  15156. dispose(): void;
  15157. /**
  15158. * Serialize the skeleton in a JSON object
  15159. * @returns a JSON object
  15160. */
  15161. serialize(): any;
  15162. /**
  15163. * Creates a new skeleton from serialized data
  15164. * @param parsedSkeleton defines the serialized data
  15165. * @param scene defines the hosting scene
  15166. * @returns a new skeleton
  15167. */
  15168. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15169. /**
  15170. * Compute all node absolute transforms
  15171. * @param forceUpdate defines if computation must be done even if cache is up to date
  15172. */
  15173. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15174. /**
  15175. * Gets the root pose matrix
  15176. * @returns a matrix
  15177. */
  15178. getPoseMatrix(): Nullable<Matrix>;
  15179. /**
  15180. * Sorts bones per internal index
  15181. */
  15182. sortBones(): void;
  15183. private _sortBones;
  15184. }
  15185. }
  15186. declare module BABYLON {
  15187. /**
  15188. * Creates an instance based on a source mesh.
  15189. */
  15190. export class InstancedMesh extends AbstractMesh {
  15191. private _sourceMesh;
  15192. private _currentLOD;
  15193. /** @hidden */
  15194. _indexInSourceMeshInstanceArray: number;
  15195. constructor(name: string, source: Mesh);
  15196. /**
  15197. * Returns the string "InstancedMesh".
  15198. */
  15199. getClassName(): string;
  15200. /** Gets the list of lights affecting that mesh */
  15201. get lightSources(): Light[];
  15202. _resyncLightSources(): void;
  15203. _resyncLightSource(light: Light): void;
  15204. _removeLightSource(light: Light, dispose: boolean): void;
  15205. /**
  15206. * If the source mesh receives shadows
  15207. */
  15208. get receiveShadows(): boolean;
  15209. /**
  15210. * The material of the source mesh
  15211. */
  15212. get material(): Nullable<Material>;
  15213. /**
  15214. * Visibility of the source mesh
  15215. */
  15216. get visibility(): number;
  15217. /**
  15218. * Skeleton of the source mesh
  15219. */
  15220. get skeleton(): Nullable<Skeleton>;
  15221. /**
  15222. * Rendering ground id of the source mesh
  15223. */
  15224. get renderingGroupId(): number;
  15225. set renderingGroupId(value: number);
  15226. /**
  15227. * Returns the total number of vertices (integer).
  15228. */
  15229. getTotalVertices(): number;
  15230. /**
  15231. * Returns a positive integer : the total number of indices in this mesh geometry.
  15232. * @returns the numner of indices or zero if the mesh has no geometry.
  15233. */
  15234. getTotalIndices(): number;
  15235. /**
  15236. * The source mesh of the instance
  15237. */
  15238. get sourceMesh(): Mesh;
  15239. /**
  15240. * Is this node ready to be used/rendered
  15241. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15242. * @return {boolean} is it ready
  15243. */
  15244. isReady(completeCheck?: boolean): boolean;
  15245. /**
  15246. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15247. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15248. * @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.
  15249. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15250. */
  15251. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15252. /**
  15253. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15254. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15255. * The `data` are either a numeric array either a Float32Array.
  15256. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15257. * 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).
  15258. * Note that a new underlying VertexBuffer object is created each call.
  15259. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15260. *
  15261. * Possible `kind` values :
  15262. * - VertexBuffer.PositionKind
  15263. * - VertexBuffer.UVKind
  15264. * - VertexBuffer.UV2Kind
  15265. * - VertexBuffer.UV3Kind
  15266. * - VertexBuffer.UV4Kind
  15267. * - VertexBuffer.UV5Kind
  15268. * - VertexBuffer.UV6Kind
  15269. * - VertexBuffer.ColorKind
  15270. * - VertexBuffer.MatricesIndicesKind
  15271. * - VertexBuffer.MatricesIndicesExtraKind
  15272. * - VertexBuffer.MatricesWeightsKind
  15273. * - VertexBuffer.MatricesWeightsExtraKind
  15274. *
  15275. * Returns the Mesh.
  15276. */
  15277. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15278. /**
  15279. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15280. * If the mesh has no geometry, it is simply returned as it is.
  15281. * The `data` are either a numeric array either a Float32Array.
  15282. * No new underlying VertexBuffer object is created.
  15283. * 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.
  15284. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15285. *
  15286. * Possible `kind` values :
  15287. * - VertexBuffer.PositionKind
  15288. * - VertexBuffer.UVKind
  15289. * - VertexBuffer.UV2Kind
  15290. * - VertexBuffer.UV3Kind
  15291. * - VertexBuffer.UV4Kind
  15292. * - VertexBuffer.UV5Kind
  15293. * - VertexBuffer.UV6Kind
  15294. * - VertexBuffer.ColorKind
  15295. * - VertexBuffer.MatricesIndicesKind
  15296. * - VertexBuffer.MatricesIndicesExtraKind
  15297. * - VertexBuffer.MatricesWeightsKind
  15298. * - VertexBuffer.MatricesWeightsExtraKind
  15299. *
  15300. * Returns the Mesh.
  15301. */
  15302. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15303. /**
  15304. * Sets the mesh indices.
  15305. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15306. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15307. * This method creates a new index buffer each call.
  15308. * Returns the Mesh.
  15309. */
  15310. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15311. /**
  15312. * Boolean : True if the mesh owns the requested kind of data.
  15313. */
  15314. isVerticesDataPresent(kind: string): boolean;
  15315. /**
  15316. * Returns an array of indices (IndicesArray).
  15317. */
  15318. getIndices(): Nullable<IndicesArray>;
  15319. get _positions(): Nullable<Vector3[]>;
  15320. /**
  15321. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15322. * This means the mesh underlying bounding box and sphere are recomputed.
  15323. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15324. * @returns the current mesh
  15325. */
  15326. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15327. /** @hidden */
  15328. _preActivate(): InstancedMesh;
  15329. /** @hidden */
  15330. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15331. /** @hidden */
  15332. _postActivate(): void;
  15333. getWorldMatrix(): Matrix;
  15334. get isAnInstance(): boolean;
  15335. /**
  15336. * Returns the current associated LOD AbstractMesh.
  15337. */
  15338. getLOD(camera: Camera): AbstractMesh;
  15339. /** @hidden */
  15340. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15341. /** @hidden */
  15342. _syncSubMeshes(): InstancedMesh;
  15343. /** @hidden */
  15344. _generatePointsArray(): boolean;
  15345. /**
  15346. * Creates a new InstancedMesh from the current mesh.
  15347. * - name (string) : the cloned mesh name
  15348. * - newParent (optional Node) : the optional Node to parent the clone to.
  15349. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15350. *
  15351. * Returns the clone.
  15352. */
  15353. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15354. /**
  15355. * Disposes the InstancedMesh.
  15356. * Returns nothing.
  15357. */
  15358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15359. }
  15360. interface Mesh {
  15361. /**
  15362. * Register a custom buffer that will be instanced
  15363. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15364. * @param kind defines the buffer kind
  15365. * @param stride defines the stride in floats
  15366. */
  15367. registerInstancedBuffer(kind: string, stride: number): void;
  15368. /** @hidden */
  15369. _userInstancedBuffersStorage: {
  15370. data: {
  15371. [key: string]: Float32Array;
  15372. };
  15373. sizes: {
  15374. [key: string]: number;
  15375. };
  15376. vertexBuffers: {
  15377. [key: string]: Nullable<VertexBuffer>;
  15378. };
  15379. strides: {
  15380. [key: string]: number;
  15381. };
  15382. };
  15383. }
  15384. interface AbstractMesh {
  15385. /**
  15386. * Object used to store instanced buffers defined by user
  15387. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15388. */
  15389. instancedBuffers: {
  15390. [key: string]: any;
  15391. };
  15392. }
  15393. }
  15394. declare module BABYLON {
  15395. /**
  15396. * Defines the options associated with the creation of a shader material.
  15397. */
  15398. export interface IShaderMaterialOptions {
  15399. /**
  15400. * Does the material work in alpha blend mode
  15401. */
  15402. needAlphaBlending: boolean;
  15403. /**
  15404. * Does the material work in alpha test mode
  15405. */
  15406. needAlphaTesting: boolean;
  15407. /**
  15408. * The list of attribute names used in the shader
  15409. */
  15410. attributes: string[];
  15411. /**
  15412. * The list of unifrom names used in the shader
  15413. */
  15414. uniforms: string[];
  15415. /**
  15416. * The list of UBO names used in the shader
  15417. */
  15418. uniformBuffers: string[];
  15419. /**
  15420. * The list of sampler names used in the shader
  15421. */
  15422. samplers: string[];
  15423. /**
  15424. * The list of defines used in the shader
  15425. */
  15426. defines: string[];
  15427. }
  15428. /**
  15429. * 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.
  15430. *
  15431. * This returned material effects how the mesh will look based on the code in the shaders.
  15432. *
  15433. * @see http://doc.babylonjs.com/how_to/shader_material
  15434. */
  15435. export class ShaderMaterial extends Material {
  15436. private _shaderPath;
  15437. private _options;
  15438. private _textures;
  15439. private _textureArrays;
  15440. private _floats;
  15441. private _ints;
  15442. private _floatsArrays;
  15443. private _colors3;
  15444. private _colors3Arrays;
  15445. private _colors4;
  15446. private _colors4Arrays;
  15447. private _vectors2;
  15448. private _vectors3;
  15449. private _vectors4;
  15450. private _matrices;
  15451. private _matrixArrays;
  15452. private _matrices3x3;
  15453. private _matrices2x2;
  15454. private _vectors2Arrays;
  15455. private _vectors3Arrays;
  15456. private _vectors4Arrays;
  15457. private _cachedWorldViewMatrix;
  15458. private _cachedWorldViewProjectionMatrix;
  15459. private _renderId;
  15460. private _multiview;
  15461. /**
  15462. * Instantiate a new shader material.
  15463. * 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.
  15464. * This returned material effects how the mesh will look based on the code in the shaders.
  15465. * @see http://doc.babylonjs.com/how_to/shader_material
  15466. * @param name Define the name of the material in the scene
  15467. * @param scene Define the scene the material belongs to
  15468. * @param shaderPath Defines the route to the shader code in one of three ways:
  15469. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15470. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15471. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15472. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15473. * @param options Define the options used to create the shader
  15474. */
  15475. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15476. /**
  15477. * Gets the shader path used to define the shader code
  15478. * It can be modified to trigger a new compilation
  15479. */
  15480. get shaderPath(): any;
  15481. /**
  15482. * Sets the shader path used to define the shader code
  15483. * It can be modified to trigger a new compilation
  15484. */
  15485. set shaderPath(shaderPath: any);
  15486. /**
  15487. * Gets the options used to compile the shader.
  15488. * They can be modified to trigger a new compilation
  15489. */
  15490. get options(): IShaderMaterialOptions;
  15491. /**
  15492. * Gets the current class name of the material e.g. "ShaderMaterial"
  15493. * Mainly use in serialization.
  15494. * @returns the class name
  15495. */
  15496. getClassName(): string;
  15497. /**
  15498. * Specifies if the material will require alpha blending
  15499. * @returns a boolean specifying if alpha blending is needed
  15500. */
  15501. needAlphaBlending(): boolean;
  15502. /**
  15503. * Specifies if this material should be rendered in alpha test mode
  15504. * @returns a boolean specifying if an alpha test is needed.
  15505. */
  15506. needAlphaTesting(): boolean;
  15507. private _checkUniform;
  15508. /**
  15509. * Set a texture in the shader.
  15510. * @param name Define the name of the uniform samplers as defined in the shader
  15511. * @param texture Define the texture to bind to this sampler
  15512. * @return the material itself allowing "fluent" like uniform updates
  15513. */
  15514. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15515. /**
  15516. * Set a texture array in the shader.
  15517. * @param name Define the name of the uniform sampler array as defined in the shader
  15518. * @param textures Define the list of textures to bind to this sampler
  15519. * @return the material itself allowing "fluent" like uniform updates
  15520. */
  15521. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15522. /**
  15523. * Set a float in the shader.
  15524. * @param name Define the name of the uniform as defined in the shader
  15525. * @param value Define the value to give to the uniform
  15526. * @return the material itself allowing "fluent" like uniform updates
  15527. */
  15528. setFloat(name: string, value: number): ShaderMaterial;
  15529. /**
  15530. * Set a int in the shader.
  15531. * @param name Define the name of the uniform as defined in the shader
  15532. * @param value Define the value to give to the uniform
  15533. * @return the material itself allowing "fluent" like uniform updates
  15534. */
  15535. setInt(name: string, value: number): ShaderMaterial;
  15536. /**
  15537. * Set an array of floats in the shader.
  15538. * @param name Define the name of the uniform as defined in the shader
  15539. * @param value Define the value to give to the uniform
  15540. * @return the material itself allowing "fluent" like uniform updates
  15541. */
  15542. setFloats(name: string, value: number[]): ShaderMaterial;
  15543. /**
  15544. * Set a vec3 in the shader from a Color3.
  15545. * @param name Define the name of the uniform as defined in the shader
  15546. * @param value Define the value to give to the uniform
  15547. * @return the material itself allowing "fluent" like uniform updates
  15548. */
  15549. setColor3(name: string, value: Color3): ShaderMaterial;
  15550. /**
  15551. * Set a vec3 array in the shader from a Color3 array.
  15552. * @param name Define the name of the uniform as defined in the shader
  15553. * @param value Define the value to give to the uniform
  15554. * @return the material itself allowing "fluent" like uniform updates
  15555. */
  15556. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15557. /**
  15558. * Set a vec4 in the shader from a Color4.
  15559. * @param name Define the name of the uniform as defined in the shader
  15560. * @param value Define the value to give to the uniform
  15561. * @return the material itself allowing "fluent" like uniform updates
  15562. */
  15563. setColor4(name: string, value: Color4): ShaderMaterial;
  15564. /**
  15565. * Set a vec4 array in the shader from a Color4 array.
  15566. * @param name Define the name of the uniform as defined in the shader
  15567. * @param value Define the value to give to the uniform
  15568. * @return the material itself allowing "fluent" like uniform updates
  15569. */
  15570. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15571. /**
  15572. * Set a vec2 in the shader from a Vector2.
  15573. * @param name Define the name of the uniform as defined in the shader
  15574. * @param value Define the value to give to the uniform
  15575. * @return the material itself allowing "fluent" like uniform updates
  15576. */
  15577. setVector2(name: string, value: Vector2): ShaderMaterial;
  15578. /**
  15579. * Set a vec3 in the shader from a Vector3.
  15580. * @param name Define the name of the uniform as defined in the shader
  15581. * @param value Define the value to give to the uniform
  15582. * @return the material itself allowing "fluent" like uniform updates
  15583. */
  15584. setVector3(name: string, value: Vector3): ShaderMaterial;
  15585. /**
  15586. * Set a vec4 in the shader from a Vector4.
  15587. * @param name Define the name of the uniform as defined in the shader
  15588. * @param value Define the value to give to the uniform
  15589. * @return the material itself allowing "fluent" like uniform updates
  15590. */
  15591. setVector4(name: string, value: Vector4): ShaderMaterial;
  15592. /**
  15593. * Set a mat4 in the shader from a Matrix.
  15594. * @param name Define the name of the uniform as defined in the shader
  15595. * @param value Define the value to give to the uniform
  15596. * @return the material itself allowing "fluent" like uniform updates
  15597. */
  15598. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15599. /**
  15600. * Set a float32Array in the shader from a matrix array.
  15601. * @param name Define the name of the uniform as defined in the shader
  15602. * @param value Define the value to give to the uniform
  15603. * @return the material itself allowing "fluent" like uniform updates
  15604. */
  15605. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15606. /**
  15607. * Set a mat3 in the shader from a Float32Array.
  15608. * @param name Define the name of the uniform as defined in the shader
  15609. * @param value Define the value to give to the uniform
  15610. * @return the material itself allowing "fluent" like uniform updates
  15611. */
  15612. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15613. /**
  15614. * Set a mat2 in the shader from a Float32Array.
  15615. * @param name Define the name of the uniform as defined in the shader
  15616. * @param value Define the value to give to the uniform
  15617. * @return the material itself allowing "fluent" like uniform updates
  15618. */
  15619. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15620. /**
  15621. * Set a vec2 array in the shader from a number array.
  15622. * @param name Define the name of the uniform as defined in the shader
  15623. * @param value Define the value to give to the uniform
  15624. * @return the material itself allowing "fluent" like uniform updates
  15625. */
  15626. setArray2(name: string, value: number[]): ShaderMaterial;
  15627. /**
  15628. * Set a vec3 array in the shader from a number array.
  15629. * @param name Define the name of the uniform as defined in the shader
  15630. * @param value Define the value to give to the uniform
  15631. * @return the material itself allowing "fluent" like uniform updates
  15632. */
  15633. setArray3(name: string, value: number[]): ShaderMaterial;
  15634. /**
  15635. * Set a vec4 array in the shader from a number array.
  15636. * @param name Define the name of the uniform as defined in the shader
  15637. * @param value Define the value to give to the uniform
  15638. * @return the material itself allowing "fluent" like uniform updates
  15639. */
  15640. setArray4(name: string, value: number[]): ShaderMaterial;
  15641. private _checkCache;
  15642. /**
  15643. * Specifies that the submesh is ready to be used
  15644. * @param mesh defines the mesh to check
  15645. * @param subMesh defines which submesh to check
  15646. * @param useInstances specifies that instances should be used
  15647. * @returns a boolean indicating that the submesh is ready or not
  15648. */
  15649. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15650. /**
  15651. * Checks if the material is ready to render the requested mesh
  15652. * @param mesh Define the mesh to render
  15653. * @param useInstances Define whether or not the material is used with instances
  15654. * @returns true if ready, otherwise false
  15655. */
  15656. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15657. /**
  15658. * Binds the world matrix to the material
  15659. * @param world defines the world transformation matrix
  15660. */
  15661. bindOnlyWorldMatrix(world: Matrix): void;
  15662. /**
  15663. * Binds the material to the mesh
  15664. * @param world defines the world transformation matrix
  15665. * @param mesh defines the mesh to bind the material to
  15666. */
  15667. bind(world: Matrix, mesh?: Mesh): void;
  15668. /**
  15669. * Gets the active textures from the material
  15670. * @returns an array of textures
  15671. */
  15672. getActiveTextures(): BaseTexture[];
  15673. /**
  15674. * Specifies if the material uses a texture
  15675. * @param texture defines the texture to check against the material
  15676. * @returns a boolean specifying if the material uses the texture
  15677. */
  15678. hasTexture(texture: BaseTexture): boolean;
  15679. /**
  15680. * Makes a duplicate of the material, and gives it a new name
  15681. * @param name defines the new name for the duplicated material
  15682. * @returns the cloned material
  15683. */
  15684. clone(name: string): ShaderMaterial;
  15685. /**
  15686. * Disposes the material
  15687. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15688. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15689. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15690. */
  15691. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15692. /**
  15693. * Serializes this material in a JSON representation
  15694. * @returns the serialized material object
  15695. */
  15696. serialize(): any;
  15697. /**
  15698. * Creates a shader material from parsed shader material data
  15699. * @param source defines the JSON represnetation of the material
  15700. * @param scene defines the hosting scene
  15701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15702. * @returns a new material
  15703. */
  15704. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15705. }
  15706. }
  15707. declare module BABYLON {
  15708. /** @hidden */
  15709. export var colorPixelShader: {
  15710. name: string;
  15711. shader: string;
  15712. };
  15713. }
  15714. declare module BABYLON {
  15715. /** @hidden */
  15716. export var colorVertexShader: {
  15717. name: string;
  15718. shader: string;
  15719. };
  15720. }
  15721. declare module BABYLON {
  15722. /**
  15723. * Line mesh
  15724. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15725. */
  15726. export class LinesMesh extends Mesh {
  15727. /**
  15728. * If vertex color should be applied to the mesh
  15729. */
  15730. readonly useVertexColor?: boolean | undefined;
  15731. /**
  15732. * If vertex alpha should be applied to the mesh
  15733. */
  15734. readonly useVertexAlpha?: boolean | undefined;
  15735. /**
  15736. * Color of the line (Default: White)
  15737. */
  15738. color: Color3;
  15739. /**
  15740. * Alpha of the line (Default: 1)
  15741. */
  15742. alpha: number;
  15743. /**
  15744. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15745. * This margin is expressed in world space coordinates, so its value may vary.
  15746. * Default value is 0.1
  15747. */
  15748. intersectionThreshold: number;
  15749. private _colorShader;
  15750. private color4;
  15751. /**
  15752. * Creates a new LinesMesh
  15753. * @param name defines the name
  15754. * @param scene defines the hosting scene
  15755. * @param parent defines the parent mesh if any
  15756. * @param source defines the optional source LinesMesh used to clone data from
  15757. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15758. * When false, achieved by calling a clone(), also passing False.
  15759. * This will make creation of children, recursive.
  15760. * @param useVertexColor defines if this LinesMesh supports vertex color
  15761. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15762. */
  15763. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15764. /**
  15765. * If vertex color should be applied to the mesh
  15766. */
  15767. useVertexColor?: boolean | undefined,
  15768. /**
  15769. * If vertex alpha should be applied to the mesh
  15770. */
  15771. useVertexAlpha?: boolean | undefined);
  15772. private _addClipPlaneDefine;
  15773. private _removeClipPlaneDefine;
  15774. isReady(): boolean;
  15775. /**
  15776. * Returns the string "LineMesh"
  15777. */
  15778. getClassName(): string;
  15779. /**
  15780. * @hidden
  15781. */
  15782. get material(): Material;
  15783. /**
  15784. * @hidden
  15785. */
  15786. set material(value: Material);
  15787. /**
  15788. * @hidden
  15789. */
  15790. get checkCollisions(): boolean;
  15791. /** @hidden */
  15792. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15793. /** @hidden */
  15794. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15795. /**
  15796. * Disposes of the line mesh
  15797. * @param doNotRecurse If children should be disposed
  15798. */
  15799. dispose(doNotRecurse?: boolean): void;
  15800. /**
  15801. * Returns a new LineMesh object cloned from the current one.
  15802. */
  15803. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15804. /**
  15805. * Creates a new InstancedLinesMesh object from the mesh model.
  15806. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15807. * @param name defines the name of the new instance
  15808. * @returns a new InstancedLinesMesh
  15809. */
  15810. createInstance(name: string): InstancedLinesMesh;
  15811. }
  15812. /**
  15813. * Creates an instance based on a source LinesMesh
  15814. */
  15815. export class InstancedLinesMesh extends InstancedMesh {
  15816. /**
  15817. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15818. * This margin is expressed in world space coordinates, so its value may vary.
  15819. * Initilized with the intersectionThreshold value of the source LinesMesh
  15820. */
  15821. intersectionThreshold: number;
  15822. constructor(name: string, source: LinesMesh);
  15823. /**
  15824. * Returns the string "InstancedLinesMesh".
  15825. */
  15826. getClassName(): string;
  15827. }
  15828. }
  15829. declare module BABYLON {
  15830. /** @hidden */
  15831. export var linePixelShader: {
  15832. name: string;
  15833. shader: string;
  15834. };
  15835. }
  15836. declare module BABYLON {
  15837. /** @hidden */
  15838. export var lineVertexShader: {
  15839. name: string;
  15840. shader: string;
  15841. };
  15842. }
  15843. declare module BABYLON {
  15844. interface AbstractMesh {
  15845. /**
  15846. * Gets the edgesRenderer associated with the mesh
  15847. */
  15848. edgesRenderer: Nullable<EdgesRenderer>;
  15849. }
  15850. interface LinesMesh {
  15851. /**
  15852. * Enables the edge rendering mode on the mesh.
  15853. * This mode makes the mesh edges visible
  15854. * @param epsilon defines the maximal distance between two angles to detect a face
  15855. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15856. * @returns the currentAbstractMesh
  15857. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15858. */
  15859. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15860. }
  15861. interface InstancedLinesMesh {
  15862. /**
  15863. * Enables the edge rendering mode on the mesh.
  15864. * This mode makes the mesh edges visible
  15865. * @param epsilon defines the maximal distance between two angles to detect a face
  15866. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15867. * @returns the current InstancedLinesMesh
  15868. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15869. */
  15870. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15871. }
  15872. /**
  15873. * Defines the minimum contract an Edges renderer should follow.
  15874. */
  15875. export interface IEdgesRenderer extends IDisposable {
  15876. /**
  15877. * Gets or sets a boolean indicating if the edgesRenderer is active
  15878. */
  15879. isEnabled: boolean;
  15880. /**
  15881. * Renders the edges of the attached mesh,
  15882. */
  15883. render(): void;
  15884. /**
  15885. * Checks wether or not the edges renderer is ready to render.
  15886. * @return true if ready, otherwise false.
  15887. */
  15888. isReady(): boolean;
  15889. }
  15890. /**
  15891. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15892. */
  15893. export class EdgesRenderer implements IEdgesRenderer {
  15894. /**
  15895. * Define the size of the edges with an orthographic camera
  15896. */
  15897. edgesWidthScalerForOrthographic: number;
  15898. /**
  15899. * Define the size of the edges with a perspective camera
  15900. */
  15901. edgesWidthScalerForPerspective: number;
  15902. protected _source: AbstractMesh;
  15903. protected _linesPositions: number[];
  15904. protected _linesNormals: number[];
  15905. protected _linesIndices: number[];
  15906. protected _epsilon: number;
  15907. protected _indicesCount: number;
  15908. protected _lineShader: ShaderMaterial;
  15909. protected _ib: DataBuffer;
  15910. protected _buffers: {
  15911. [key: string]: Nullable<VertexBuffer>;
  15912. };
  15913. protected _checkVerticesInsteadOfIndices: boolean;
  15914. private _meshRebuildObserver;
  15915. private _meshDisposeObserver;
  15916. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15917. isEnabled: boolean;
  15918. /**
  15919. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15920. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15921. * @param source Mesh used to create edges
  15922. * @param epsilon sum of angles in adjacency to check for edge
  15923. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15924. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15925. */
  15926. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15927. protected _prepareRessources(): void;
  15928. /** @hidden */
  15929. _rebuild(): void;
  15930. /**
  15931. * Releases the required resources for the edges renderer
  15932. */
  15933. dispose(): void;
  15934. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15935. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15936. /**
  15937. * Checks if the pair of p0 and p1 is en edge
  15938. * @param faceIndex
  15939. * @param edge
  15940. * @param faceNormals
  15941. * @param p0
  15942. * @param p1
  15943. * @private
  15944. */
  15945. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15946. /**
  15947. * push line into the position, normal and index buffer
  15948. * @protected
  15949. */
  15950. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15951. /**
  15952. * Generates lines edges from adjacencjes
  15953. * @private
  15954. */
  15955. _generateEdgesLines(): void;
  15956. /**
  15957. * Checks wether or not the edges renderer is ready to render.
  15958. * @return true if ready, otherwise false.
  15959. */
  15960. isReady(): boolean;
  15961. /**
  15962. * Renders the edges of the attached mesh,
  15963. */
  15964. render(): void;
  15965. }
  15966. /**
  15967. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15968. */
  15969. export class LineEdgesRenderer extends EdgesRenderer {
  15970. /**
  15971. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15972. * @param source LineMesh used to generate edges
  15973. * @param epsilon not important (specified angle for edge detection)
  15974. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15975. */
  15976. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15977. /**
  15978. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15979. */
  15980. _generateEdgesLines(): void;
  15981. }
  15982. }
  15983. declare module BABYLON {
  15984. /**
  15985. * This represents the object necessary to create a rendering group.
  15986. * This is exclusively used and created by the rendering manager.
  15987. * To modify the behavior, you use the available helpers in your scene or meshes.
  15988. * @hidden
  15989. */
  15990. export class RenderingGroup {
  15991. index: number;
  15992. private static _zeroVector;
  15993. private _scene;
  15994. private _opaqueSubMeshes;
  15995. private _transparentSubMeshes;
  15996. private _alphaTestSubMeshes;
  15997. private _depthOnlySubMeshes;
  15998. private _particleSystems;
  15999. private _spriteManagers;
  16000. private _opaqueSortCompareFn;
  16001. private _alphaTestSortCompareFn;
  16002. private _transparentSortCompareFn;
  16003. private _renderOpaque;
  16004. private _renderAlphaTest;
  16005. private _renderTransparent;
  16006. /** @hidden */
  16007. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16008. onBeforeTransparentRendering: () => void;
  16009. /**
  16010. * Set the opaque sort comparison function.
  16011. * If null the sub meshes will be render in the order they were created
  16012. */
  16013. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16014. /**
  16015. * Set the alpha test sort comparison function.
  16016. * If null the sub meshes will be render in the order they were created
  16017. */
  16018. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16019. /**
  16020. * Set the transparent sort comparison function.
  16021. * If null the sub meshes will be render in the order they were created
  16022. */
  16023. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16024. /**
  16025. * Creates a new rendering group.
  16026. * @param index The rendering group index
  16027. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16028. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16029. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16030. */
  16031. 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>);
  16032. /**
  16033. * Render all the sub meshes contained in the group.
  16034. * @param customRenderFunction Used to override the default render behaviour of the group.
  16035. * @returns true if rendered some submeshes.
  16036. */
  16037. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16038. /**
  16039. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16040. * @param subMeshes The submeshes to render
  16041. */
  16042. private renderOpaqueSorted;
  16043. /**
  16044. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16045. * @param subMeshes The submeshes to render
  16046. */
  16047. private renderAlphaTestSorted;
  16048. /**
  16049. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16050. * @param subMeshes The submeshes to render
  16051. */
  16052. private renderTransparentSorted;
  16053. /**
  16054. * Renders the submeshes in a specified order.
  16055. * @param subMeshes The submeshes to sort before render
  16056. * @param sortCompareFn The comparison function use to sort
  16057. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16058. * @param transparent Specifies to activate blending if true
  16059. */
  16060. private static renderSorted;
  16061. /**
  16062. * Renders the submeshes in the order they were dispatched (no sort applied).
  16063. * @param subMeshes The submeshes to render
  16064. */
  16065. private static renderUnsorted;
  16066. /**
  16067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16068. * are rendered back to front if in the same alpha index.
  16069. *
  16070. * @param a The first submesh
  16071. * @param b The second submesh
  16072. * @returns The result of the comparison
  16073. */
  16074. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16075. /**
  16076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16077. * are rendered back to front.
  16078. *
  16079. * @param a The first submesh
  16080. * @param b The second submesh
  16081. * @returns The result of the comparison
  16082. */
  16083. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16084. /**
  16085. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16086. * are rendered front to back (prevent overdraw).
  16087. *
  16088. * @param a The first submesh
  16089. * @param b The second submesh
  16090. * @returns The result of the comparison
  16091. */
  16092. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16093. /**
  16094. * Resets the different lists of submeshes to prepare a new frame.
  16095. */
  16096. prepare(): void;
  16097. dispose(): void;
  16098. /**
  16099. * Inserts the submesh in its correct queue depending on its material.
  16100. * @param subMesh The submesh to dispatch
  16101. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16102. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16103. */
  16104. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16105. dispatchSprites(spriteManager: ISpriteManager): void;
  16106. dispatchParticles(particleSystem: IParticleSystem): void;
  16107. private _renderParticles;
  16108. private _renderSprites;
  16109. }
  16110. }
  16111. declare module BABYLON {
  16112. /**
  16113. * Interface describing the different options available in the rendering manager
  16114. * regarding Auto Clear between groups.
  16115. */
  16116. export interface IRenderingManagerAutoClearSetup {
  16117. /**
  16118. * Defines whether or not autoclear is enable.
  16119. */
  16120. autoClear: boolean;
  16121. /**
  16122. * Defines whether or not to autoclear the depth buffer.
  16123. */
  16124. depth: boolean;
  16125. /**
  16126. * Defines whether or not to autoclear the stencil buffer.
  16127. */
  16128. stencil: boolean;
  16129. }
  16130. /**
  16131. * This class is used by the onRenderingGroupObservable
  16132. */
  16133. export class RenderingGroupInfo {
  16134. /**
  16135. * The Scene that being rendered
  16136. */
  16137. scene: Scene;
  16138. /**
  16139. * The camera currently used for the rendering pass
  16140. */
  16141. camera: Nullable<Camera>;
  16142. /**
  16143. * The ID of the renderingGroup being processed
  16144. */
  16145. renderingGroupId: number;
  16146. }
  16147. /**
  16148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16149. * It is enable to manage the different groups as well as the different necessary sort functions.
  16150. * This should not be used directly aside of the few static configurations
  16151. */
  16152. export class RenderingManager {
  16153. /**
  16154. * The max id used for rendering groups (not included)
  16155. */
  16156. static MAX_RENDERINGGROUPS: number;
  16157. /**
  16158. * The min id used for rendering groups (included)
  16159. */
  16160. static MIN_RENDERINGGROUPS: number;
  16161. /**
  16162. * Used to globally prevent autoclearing scenes.
  16163. */
  16164. static AUTOCLEAR: boolean;
  16165. /**
  16166. * @hidden
  16167. */
  16168. _useSceneAutoClearSetup: boolean;
  16169. private _scene;
  16170. private _renderingGroups;
  16171. private _depthStencilBufferAlreadyCleaned;
  16172. private _autoClearDepthStencil;
  16173. private _customOpaqueSortCompareFn;
  16174. private _customAlphaTestSortCompareFn;
  16175. private _customTransparentSortCompareFn;
  16176. private _renderingGroupInfo;
  16177. /**
  16178. * Instantiates a new rendering group for a particular scene
  16179. * @param scene Defines the scene the groups belongs to
  16180. */
  16181. constructor(scene: Scene);
  16182. private _clearDepthStencilBuffer;
  16183. /**
  16184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16185. * @hidden
  16186. */
  16187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16188. /**
  16189. * Resets the different information of the group to prepare a new frame
  16190. * @hidden
  16191. */
  16192. reset(): void;
  16193. /**
  16194. * Dispose and release the group and its associated resources.
  16195. * @hidden
  16196. */
  16197. dispose(): void;
  16198. /**
  16199. * Clear the info related to rendering groups preventing retention points during dispose.
  16200. */
  16201. freeRenderingGroups(): void;
  16202. private _prepareRenderingGroup;
  16203. /**
  16204. * Add a sprite manager to the rendering manager in order to render it this frame.
  16205. * @param spriteManager Define the sprite manager to render
  16206. */
  16207. dispatchSprites(spriteManager: ISpriteManager): void;
  16208. /**
  16209. * Add a particle system to the rendering manager in order to render it this frame.
  16210. * @param particleSystem Define the particle system to render
  16211. */
  16212. dispatchParticles(particleSystem: IParticleSystem): void;
  16213. /**
  16214. * Add a submesh to the manager in order to render it this frame
  16215. * @param subMesh The submesh to dispatch
  16216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16218. */
  16219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16220. /**
  16221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16222. * This allowed control for front to back rendering or reversly depending of the special needs.
  16223. *
  16224. * @param renderingGroupId The rendering group id corresponding to its index
  16225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16228. */
  16229. 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;
  16230. /**
  16231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16232. *
  16233. * @param renderingGroupId The rendering group id corresponding to its index
  16234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16237. */
  16238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16239. /**
  16240. * Gets the current auto clear configuration for one rendering group of the rendering
  16241. * manager.
  16242. * @param index the rendering group index to get the information for
  16243. * @returns The auto clear setup for the requested rendering group
  16244. */
  16245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16246. }
  16247. }
  16248. declare module BABYLON {
  16249. /**
  16250. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16251. */
  16252. export interface ICustomShaderOptions {
  16253. /**
  16254. * Gets or sets the custom shader name to use
  16255. */
  16256. shaderName: string;
  16257. /**
  16258. * The list of attribute names used in the shader
  16259. */
  16260. attributes?: string[];
  16261. /**
  16262. * The list of unifrom names used in the shader
  16263. */
  16264. uniforms?: string[];
  16265. /**
  16266. * The list of sampler names used in the shader
  16267. */
  16268. samplers?: string[];
  16269. /**
  16270. * The list of defines used in the shader
  16271. */
  16272. defines?: string[];
  16273. }
  16274. /**
  16275. * Interface to implement to create a shadow generator compatible with BJS.
  16276. */
  16277. export interface IShadowGenerator {
  16278. /**
  16279. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16280. * @returns The render target texture if present otherwise, null
  16281. */
  16282. getShadowMap(): Nullable<RenderTargetTexture>;
  16283. /**
  16284. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16285. * @param subMesh The submesh we want to render in the shadow map
  16286. * @param useInstances Defines wether will draw in the map using instances
  16287. * @returns true if ready otherwise, false
  16288. */
  16289. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16290. /**
  16291. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16292. * @param defines Defines of the material we want to update
  16293. * @param lightIndex Index of the light in the enabled light list of the material
  16294. */
  16295. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16296. /**
  16297. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16298. * defined in the generator but impacting the effect).
  16299. * It implies the unifroms available on the materials are the standard BJS ones.
  16300. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16301. * @param effect The effect we are binfing the information for
  16302. */
  16303. bindShadowLight(lightIndex: string, effect: Effect): void;
  16304. /**
  16305. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16306. * (eq to shadow prjection matrix * light transform matrix)
  16307. * @returns The transform matrix used to create the shadow map
  16308. */
  16309. getTransformMatrix(): Matrix;
  16310. /**
  16311. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16312. * Cube and 2D textures for instance.
  16313. */
  16314. recreateShadowMap(): void;
  16315. /**
  16316. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16317. * @param onCompiled Callback triggered at the and of the effects compilation
  16318. * @param options Sets of optional options forcing the compilation with different modes
  16319. */
  16320. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16321. useInstances: boolean;
  16322. }>): void;
  16323. /**
  16324. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16325. * @param options Sets of optional options forcing the compilation with different modes
  16326. * @returns A promise that resolves when the compilation completes
  16327. */
  16328. forceCompilationAsync(options?: Partial<{
  16329. useInstances: boolean;
  16330. }>): Promise<void>;
  16331. /**
  16332. * Serializes the shadow generator setup to a json object.
  16333. * @returns The serialized JSON object
  16334. */
  16335. serialize(): any;
  16336. /**
  16337. * Disposes the Shadow map and related Textures and effects.
  16338. */
  16339. dispose(): void;
  16340. }
  16341. /**
  16342. * Default implementation IShadowGenerator.
  16343. * This is the main object responsible of generating shadows in the framework.
  16344. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16345. */
  16346. export class ShadowGenerator implements IShadowGenerator {
  16347. /**
  16348. * Name of the shadow generator class
  16349. */
  16350. static CLASSNAME: string;
  16351. /**
  16352. * Shadow generator mode None: no filtering applied.
  16353. */
  16354. static readonly FILTER_NONE: number;
  16355. /**
  16356. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16357. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16358. */
  16359. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16360. /**
  16361. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16362. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16363. */
  16364. static readonly FILTER_POISSONSAMPLING: number;
  16365. /**
  16366. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16367. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16368. */
  16369. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16370. /**
  16371. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16372. * edge artifacts on steep falloff.
  16373. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16374. */
  16375. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16376. /**
  16377. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16378. * edge artifacts on steep falloff.
  16379. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16380. */
  16381. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16382. /**
  16383. * Shadow generator mode PCF: Percentage Closer Filtering
  16384. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16385. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16386. */
  16387. static readonly FILTER_PCF: number;
  16388. /**
  16389. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16390. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16391. * Contact Hardening
  16392. */
  16393. static readonly FILTER_PCSS: number;
  16394. /**
  16395. * Reserved for PCF and PCSS
  16396. * Highest Quality.
  16397. *
  16398. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16399. *
  16400. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16401. */
  16402. static readonly QUALITY_HIGH: number;
  16403. /**
  16404. * Reserved for PCF and PCSS
  16405. * Good tradeoff for quality/perf cross devices
  16406. *
  16407. * Execute PCF on a 3*3 kernel.
  16408. *
  16409. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16410. */
  16411. static readonly QUALITY_MEDIUM: number;
  16412. /**
  16413. * Reserved for PCF and PCSS
  16414. * The lowest quality but the fastest.
  16415. *
  16416. * Execute PCF on a 1*1 kernel.
  16417. *
  16418. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16419. */
  16420. static readonly QUALITY_LOW: number;
  16421. /** Gets or sets the custom shader name to use */
  16422. customShaderOptions: ICustomShaderOptions;
  16423. /**
  16424. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16425. */
  16426. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16427. /**
  16428. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16429. */
  16430. onAfterShadowMapRenderObservable: Observable<Effect>;
  16431. /**
  16432. * Observable triggered before a mesh is rendered in the shadow map.
  16433. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16434. */
  16435. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16436. /**
  16437. * Observable triggered after a mesh is rendered in the shadow map.
  16438. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16439. */
  16440. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16441. protected _bias: number;
  16442. /**
  16443. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16444. */
  16445. get bias(): number;
  16446. /**
  16447. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16448. */
  16449. set bias(bias: number);
  16450. protected _normalBias: number;
  16451. /**
  16452. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16453. */
  16454. get normalBias(): number;
  16455. /**
  16456. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16457. */
  16458. set normalBias(normalBias: number);
  16459. protected _blurBoxOffset: number;
  16460. /**
  16461. * Gets the blur box offset: offset applied during the blur pass.
  16462. * Only useful if useKernelBlur = false
  16463. */
  16464. get blurBoxOffset(): number;
  16465. /**
  16466. * Sets the blur box offset: offset applied during the blur pass.
  16467. * Only useful if useKernelBlur = false
  16468. */
  16469. set blurBoxOffset(value: number);
  16470. protected _blurScale: number;
  16471. /**
  16472. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16473. * 2 means half of the size.
  16474. */
  16475. get blurScale(): number;
  16476. /**
  16477. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16478. * 2 means half of the size.
  16479. */
  16480. set blurScale(value: number);
  16481. protected _blurKernel: number;
  16482. /**
  16483. * Gets the blur kernel: kernel size of the blur pass.
  16484. * Only useful if useKernelBlur = true
  16485. */
  16486. get blurKernel(): number;
  16487. /**
  16488. * Sets the blur kernel: kernel size of the blur pass.
  16489. * Only useful if useKernelBlur = true
  16490. */
  16491. set blurKernel(value: number);
  16492. protected _useKernelBlur: boolean;
  16493. /**
  16494. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16495. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16496. */
  16497. get useKernelBlur(): boolean;
  16498. /**
  16499. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16500. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16501. */
  16502. set useKernelBlur(value: boolean);
  16503. protected _depthScale: number;
  16504. /**
  16505. * Gets the depth scale used in ESM mode.
  16506. */
  16507. get depthScale(): number;
  16508. /**
  16509. * Sets the depth scale used in ESM mode.
  16510. * This can override the scale stored on the light.
  16511. */
  16512. set depthScale(value: number);
  16513. protected _validateFilter(filter: number): number;
  16514. protected _filter: number;
  16515. /**
  16516. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16517. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16518. */
  16519. get filter(): number;
  16520. /**
  16521. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16522. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16523. */
  16524. set filter(value: number);
  16525. /**
  16526. * Gets if the current filter is set to Poisson Sampling.
  16527. */
  16528. get usePoissonSampling(): boolean;
  16529. /**
  16530. * Sets the current filter to Poisson Sampling.
  16531. */
  16532. set usePoissonSampling(value: boolean);
  16533. /**
  16534. * Gets if the current filter is set to ESM.
  16535. */
  16536. get useExponentialShadowMap(): boolean;
  16537. /**
  16538. * Sets the current filter is to ESM.
  16539. */
  16540. set useExponentialShadowMap(value: boolean);
  16541. /**
  16542. * Gets if the current filter is set to filtered ESM.
  16543. */
  16544. get useBlurExponentialShadowMap(): boolean;
  16545. /**
  16546. * Gets if the current filter is set to filtered ESM.
  16547. */
  16548. set useBlurExponentialShadowMap(value: boolean);
  16549. /**
  16550. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16551. * exponential to prevent steep falloff artifacts).
  16552. */
  16553. get useCloseExponentialShadowMap(): boolean;
  16554. /**
  16555. * Sets the current filter to "close ESM" (using the inverse of the
  16556. * exponential to prevent steep falloff artifacts).
  16557. */
  16558. set useCloseExponentialShadowMap(value: boolean);
  16559. /**
  16560. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16561. * exponential to prevent steep falloff artifacts).
  16562. */
  16563. get useBlurCloseExponentialShadowMap(): boolean;
  16564. /**
  16565. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16566. * exponential to prevent steep falloff artifacts).
  16567. */
  16568. set useBlurCloseExponentialShadowMap(value: boolean);
  16569. /**
  16570. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16571. */
  16572. get usePercentageCloserFiltering(): boolean;
  16573. /**
  16574. * Sets the current filter to "PCF" (percentage closer filtering).
  16575. */
  16576. set usePercentageCloserFiltering(value: boolean);
  16577. protected _filteringQuality: number;
  16578. /**
  16579. * Gets the PCF or PCSS Quality.
  16580. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16581. */
  16582. get filteringQuality(): number;
  16583. /**
  16584. * Sets the PCF or PCSS Quality.
  16585. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16586. */
  16587. set filteringQuality(filteringQuality: number);
  16588. /**
  16589. * Gets if the current filter is set to "PCSS" (contact hardening).
  16590. */
  16591. get useContactHardeningShadow(): boolean;
  16592. /**
  16593. * Sets the current filter to "PCSS" (contact hardening).
  16594. */
  16595. set useContactHardeningShadow(value: boolean);
  16596. protected _contactHardeningLightSizeUVRatio: number;
  16597. /**
  16598. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16599. * Using a ratio helps keeping shape stability independently of the map size.
  16600. *
  16601. * It does not account for the light projection as it was having too much
  16602. * instability during the light setup or during light position changes.
  16603. *
  16604. * Only valid if useContactHardeningShadow is true.
  16605. */
  16606. get contactHardeningLightSizeUVRatio(): number;
  16607. /**
  16608. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16609. * Using a ratio helps keeping shape stability independently of the map size.
  16610. *
  16611. * It does not account for the light projection as it was having too much
  16612. * instability during the light setup or during light position changes.
  16613. *
  16614. * Only valid if useContactHardeningShadow is true.
  16615. */
  16616. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16617. protected _darkness: number;
  16618. /** Gets or sets the actual darkness of a shadow */
  16619. get darkness(): number;
  16620. set darkness(value: number);
  16621. /**
  16622. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16623. * 0 means strongest and 1 would means no shadow.
  16624. * @returns the darkness.
  16625. */
  16626. getDarkness(): number;
  16627. /**
  16628. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16629. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16630. * @returns the shadow generator allowing fluent coding.
  16631. */
  16632. setDarkness(darkness: number): ShadowGenerator;
  16633. protected _transparencyShadow: boolean;
  16634. /** Gets or sets the ability to have transparent shadow */
  16635. get transparencyShadow(): boolean;
  16636. set transparencyShadow(value: boolean);
  16637. /**
  16638. * Sets the ability to have transparent shadow (boolean).
  16639. * @param transparent True if transparent else False
  16640. * @returns the shadow generator allowing fluent coding
  16641. */
  16642. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16643. protected _shadowMap: Nullable<RenderTargetTexture>;
  16644. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16645. /**
  16646. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16647. * @returns The render target texture if present otherwise, null
  16648. */
  16649. getShadowMap(): Nullable<RenderTargetTexture>;
  16650. /**
  16651. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16652. * @returns The render target texture if the shadow map is present otherwise, null
  16653. */
  16654. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16655. /**
  16656. * Gets the class name of that object
  16657. * @returns "ShadowGenerator"
  16658. */
  16659. getClassName(): string;
  16660. /**
  16661. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16662. * @param mesh Mesh to add
  16663. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16664. * @returns the Shadow Generator itself
  16665. */
  16666. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16667. /**
  16668. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16669. * @param mesh Mesh to remove
  16670. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16671. * @returns the Shadow Generator itself
  16672. */
  16673. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16674. /**
  16675. * Controls the extent to which the shadows fade out at the edge of the frustum
  16676. */
  16677. frustumEdgeFalloff: number;
  16678. protected _light: IShadowLight;
  16679. /**
  16680. * Returns the associated light object.
  16681. * @returns the light generating the shadow
  16682. */
  16683. getLight(): IShadowLight;
  16684. /**
  16685. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16686. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16687. * It might on the other hand introduce peter panning.
  16688. */
  16689. forceBackFacesOnly: boolean;
  16690. protected _scene: Scene;
  16691. protected _lightDirection: Vector3;
  16692. protected _effect: Effect;
  16693. protected _viewMatrix: Matrix;
  16694. protected _projectionMatrix: Matrix;
  16695. protected _transformMatrix: Matrix;
  16696. protected _cachedPosition: Vector3;
  16697. protected _cachedDirection: Vector3;
  16698. protected _cachedDefines: string;
  16699. protected _currentRenderID: number;
  16700. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16701. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16702. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16703. protected _blurPostProcesses: PostProcess[];
  16704. protected _mapSize: number;
  16705. protected _currentFaceIndex: number;
  16706. protected _currentFaceIndexCache: number;
  16707. protected _textureType: number;
  16708. protected _defaultTextureMatrix: Matrix;
  16709. protected _storedUniqueId: Nullable<number>;
  16710. /** @hidden */
  16711. static _SceneComponentInitialization: (scene: Scene) => void;
  16712. /**
  16713. * Creates a ShadowGenerator object.
  16714. * A ShadowGenerator is the required tool to use the shadows.
  16715. * Each light casting shadows needs to use its own ShadowGenerator.
  16716. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16717. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16718. * @param light The light object generating the shadows.
  16719. * @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.
  16720. */
  16721. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16722. protected _initializeGenerator(): void;
  16723. protected _createTargetRenderTexture(): void;
  16724. protected _initializeShadowMap(): void;
  16725. protected _initializeBlurRTTAndPostProcesses(): void;
  16726. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16727. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16728. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16729. protected _applyFilterValues(): void;
  16730. /**
  16731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16732. * @param onCompiled Callback triggered at the and of the effects compilation
  16733. * @param options Sets of optional options forcing the compilation with different modes
  16734. */
  16735. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16736. useInstances: boolean;
  16737. }>): void;
  16738. /**
  16739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16740. * @param options Sets of optional options forcing the compilation with different modes
  16741. * @returns A promise that resolves when the compilation completes
  16742. */
  16743. forceCompilationAsync(options?: Partial<{
  16744. useInstances: boolean;
  16745. }>): Promise<void>;
  16746. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16747. /**
  16748. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16749. * @param subMesh The submesh we want to render in the shadow map
  16750. * @param useInstances Defines wether will draw in the map using instances
  16751. * @returns true if ready otherwise, false
  16752. */
  16753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16754. /**
  16755. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16756. * @param defines Defines of the material we want to update
  16757. * @param lightIndex Index of the light in the enabled light list of the material
  16758. */
  16759. prepareDefines(defines: any, lightIndex: number): void;
  16760. /**
  16761. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16762. * defined in the generator but impacting the effect).
  16763. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16764. * @param effect The effect we are binfing the information for
  16765. */
  16766. bindShadowLight(lightIndex: string, effect: Effect): void;
  16767. /**
  16768. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16769. * (eq to shadow prjection matrix * light transform matrix)
  16770. * @returns The transform matrix used to create the shadow map
  16771. */
  16772. getTransformMatrix(): Matrix;
  16773. /**
  16774. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16775. * Cube and 2D textures for instance.
  16776. */
  16777. recreateShadowMap(): void;
  16778. protected _disposeBlurPostProcesses(): void;
  16779. protected _disposeRTTandPostProcesses(): void;
  16780. /**
  16781. * Disposes the ShadowGenerator.
  16782. * Returns nothing.
  16783. */
  16784. dispose(): void;
  16785. /**
  16786. * Serializes the shadow generator setup to a json object.
  16787. * @returns The serialized JSON object
  16788. */
  16789. serialize(): any;
  16790. /**
  16791. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16792. * @param parsedShadowGenerator The JSON object to parse
  16793. * @param scene The scene to create the shadow map for
  16794. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16795. * @returns The parsed shadow generator
  16796. */
  16797. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16798. }
  16799. }
  16800. declare module BABYLON {
  16801. /**
  16802. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16803. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16804. * 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.
  16805. */
  16806. export abstract class Light extends Node {
  16807. /**
  16808. * Falloff Default: light is falling off following the material specification:
  16809. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16810. */
  16811. static readonly FALLOFF_DEFAULT: number;
  16812. /**
  16813. * Falloff Physical: light is falling off following the inverse squared distance law.
  16814. */
  16815. static readonly FALLOFF_PHYSICAL: number;
  16816. /**
  16817. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16818. * to enhance interoperability with other engines.
  16819. */
  16820. static readonly FALLOFF_GLTF: number;
  16821. /**
  16822. * Falloff Standard: light is falling off like in the standard material
  16823. * to enhance interoperability with other materials.
  16824. */
  16825. static readonly FALLOFF_STANDARD: number;
  16826. /**
  16827. * If every light affecting the material is in this lightmapMode,
  16828. * material.lightmapTexture adds or multiplies
  16829. * (depends on material.useLightmapAsShadowmap)
  16830. * after every other light calculations.
  16831. */
  16832. static readonly LIGHTMAP_DEFAULT: number;
  16833. /**
  16834. * material.lightmapTexture as only diffuse lighting from this light
  16835. * adds only specular lighting from this light
  16836. * adds dynamic shadows
  16837. */
  16838. static readonly LIGHTMAP_SPECULAR: number;
  16839. /**
  16840. * material.lightmapTexture as only lighting
  16841. * no light calculation from this light
  16842. * only adds dynamic shadows from this light
  16843. */
  16844. static readonly LIGHTMAP_SHADOWSONLY: number;
  16845. /**
  16846. * Each light type uses the default quantity according to its type:
  16847. * point/spot lights use luminous intensity
  16848. * directional lights use illuminance
  16849. */
  16850. static readonly INTENSITYMODE_AUTOMATIC: number;
  16851. /**
  16852. * lumen (lm)
  16853. */
  16854. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16855. /**
  16856. * candela (lm/sr)
  16857. */
  16858. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16859. /**
  16860. * lux (lm/m^2)
  16861. */
  16862. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16863. /**
  16864. * nit (cd/m^2)
  16865. */
  16866. static readonly INTENSITYMODE_LUMINANCE: number;
  16867. /**
  16868. * Light type const id of the point light.
  16869. */
  16870. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16871. /**
  16872. * Light type const id of the directional light.
  16873. */
  16874. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16875. /**
  16876. * Light type const id of the spot light.
  16877. */
  16878. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16879. /**
  16880. * Light type const id of the hemispheric light.
  16881. */
  16882. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16883. /**
  16884. * Diffuse gives the basic color to an object.
  16885. */
  16886. diffuse: Color3;
  16887. /**
  16888. * Specular produces a highlight color on an object.
  16889. * Note: This is note affecting PBR materials.
  16890. */
  16891. specular: Color3;
  16892. /**
  16893. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16894. * falling off base on range or angle.
  16895. * This can be set to any values in Light.FALLOFF_x.
  16896. *
  16897. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16898. * other types of materials.
  16899. */
  16900. falloffType: number;
  16901. /**
  16902. * Strength of the light.
  16903. * Note: By default it is define in the framework own unit.
  16904. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16905. */
  16906. intensity: number;
  16907. private _range;
  16908. protected _inverseSquaredRange: number;
  16909. /**
  16910. * Defines how far from the source the light is impacting in scene units.
  16911. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16912. */
  16913. get range(): number;
  16914. /**
  16915. * Defines how far from the source the light is impacting in scene units.
  16916. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16917. */
  16918. set range(value: number);
  16919. /**
  16920. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16921. * of light.
  16922. */
  16923. private _photometricScale;
  16924. private _intensityMode;
  16925. /**
  16926. * Gets the photometric scale used to interpret the intensity.
  16927. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16928. */
  16929. get intensityMode(): number;
  16930. /**
  16931. * Sets the photometric scale used to interpret the intensity.
  16932. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16933. */
  16934. set intensityMode(value: number);
  16935. private _radius;
  16936. /**
  16937. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16938. */
  16939. get radius(): number;
  16940. /**
  16941. * sets the light radius used by PBR Materials to simulate soft area lights.
  16942. */
  16943. set radius(value: number);
  16944. private _renderPriority;
  16945. /**
  16946. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16947. * exceeding the number allowed of the materials.
  16948. */
  16949. renderPriority: number;
  16950. private _shadowEnabled;
  16951. /**
  16952. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16953. * the current shadow generator.
  16954. */
  16955. get shadowEnabled(): boolean;
  16956. /**
  16957. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16958. * the current shadow generator.
  16959. */
  16960. set shadowEnabled(value: boolean);
  16961. private _includedOnlyMeshes;
  16962. /**
  16963. * Gets the only meshes impacted by this light.
  16964. */
  16965. get includedOnlyMeshes(): AbstractMesh[];
  16966. /**
  16967. * Sets the only meshes impacted by this light.
  16968. */
  16969. set includedOnlyMeshes(value: AbstractMesh[]);
  16970. private _excludedMeshes;
  16971. /**
  16972. * Gets the meshes not impacted by this light.
  16973. */
  16974. get excludedMeshes(): AbstractMesh[];
  16975. /**
  16976. * Sets the meshes not impacted by this light.
  16977. */
  16978. set excludedMeshes(value: AbstractMesh[]);
  16979. private _excludeWithLayerMask;
  16980. /**
  16981. * Gets the layer id use to find what meshes are not impacted by the light.
  16982. * Inactive if 0
  16983. */
  16984. get excludeWithLayerMask(): number;
  16985. /**
  16986. * Sets the layer id use to find what meshes are not impacted by the light.
  16987. * Inactive if 0
  16988. */
  16989. set excludeWithLayerMask(value: number);
  16990. private _includeOnlyWithLayerMask;
  16991. /**
  16992. * Gets the layer id use to find what meshes are impacted by the light.
  16993. * Inactive if 0
  16994. */
  16995. get includeOnlyWithLayerMask(): number;
  16996. /**
  16997. * Sets the layer id use to find what meshes are impacted by the light.
  16998. * Inactive if 0
  16999. */
  17000. set includeOnlyWithLayerMask(value: number);
  17001. private _lightmapMode;
  17002. /**
  17003. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17004. */
  17005. get lightmapMode(): number;
  17006. /**
  17007. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17008. */
  17009. set lightmapMode(value: number);
  17010. /**
  17011. * Shadow generator associted to the light.
  17012. * @hidden Internal use only.
  17013. */
  17014. _shadowGenerator: Nullable<IShadowGenerator>;
  17015. /**
  17016. * @hidden Internal use only.
  17017. */
  17018. _excludedMeshesIds: string[];
  17019. /**
  17020. * @hidden Internal use only.
  17021. */
  17022. _includedOnlyMeshesIds: string[];
  17023. /**
  17024. * The current light unifom buffer.
  17025. * @hidden Internal use only.
  17026. */
  17027. _uniformBuffer: UniformBuffer;
  17028. /** @hidden */
  17029. _renderId: number;
  17030. /**
  17031. * Creates a Light object in the scene.
  17032. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17033. * @param name The firendly name of the light
  17034. * @param scene The scene the light belongs too
  17035. */
  17036. constructor(name: string, scene: Scene);
  17037. protected abstract _buildUniformLayout(): void;
  17038. /**
  17039. * Sets the passed Effect "effect" with the Light information.
  17040. * @param effect The effect to update
  17041. * @param lightIndex The index of the light in the effect to update
  17042. * @returns The light
  17043. */
  17044. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17045. /**
  17046. * Sets the passed Effect "effect" with the Light textures.
  17047. * @param effect The effect to update
  17048. * @param lightIndex The index of the light in the effect to update
  17049. * @returns The light
  17050. */
  17051. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17052. /**
  17053. * Binds the lights information from the scene to the effect for the given mesh.
  17054. * @param lightIndex Light index
  17055. * @param scene The scene where the light belongs to
  17056. * @param effect The effect we are binding the data to
  17057. * @param useSpecular Defines if specular is supported
  17058. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17059. */
  17060. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17061. /**
  17062. * Sets the passed Effect "effect" with the Light information.
  17063. * @param effect The effect to update
  17064. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17065. * @returns The light
  17066. */
  17067. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17068. /**
  17069. * Returns the string "Light".
  17070. * @returns the class name
  17071. */
  17072. getClassName(): string;
  17073. /** @hidden */
  17074. readonly _isLight: boolean;
  17075. /**
  17076. * Converts the light information to a readable string for debug purpose.
  17077. * @param fullDetails Supports for multiple levels of logging within scene loading
  17078. * @returns the human readable light info
  17079. */
  17080. toString(fullDetails?: boolean): string;
  17081. /** @hidden */
  17082. protected _syncParentEnabledState(): void;
  17083. /**
  17084. * Set the enabled state of this node.
  17085. * @param value - the new enabled state
  17086. */
  17087. setEnabled(value: boolean): void;
  17088. /**
  17089. * Returns the Light associated shadow generator if any.
  17090. * @return the associated shadow generator.
  17091. */
  17092. getShadowGenerator(): Nullable<IShadowGenerator>;
  17093. /**
  17094. * Returns a Vector3, the absolute light position in the World.
  17095. * @returns the world space position of the light
  17096. */
  17097. getAbsolutePosition(): Vector3;
  17098. /**
  17099. * Specifies if the light will affect the passed mesh.
  17100. * @param mesh The mesh to test against the light
  17101. * @return true the mesh is affected otherwise, false.
  17102. */
  17103. canAffectMesh(mesh: AbstractMesh): boolean;
  17104. /**
  17105. * Sort function to order lights for rendering.
  17106. * @param a First Light object to compare to second.
  17107. * @param b Second Light object to compare first.
  17108. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17109. */
  17110. static CompareLightsPriority(a: Light, b: Light): number;
  17111. /**
  17112. * Releases resources associated with this node.
  17113. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17114. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17115. */
  17116. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17117. /**
  17118. * Returns the light type ID (integer).
  17119. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17120. */
  17121. getTypeID(): number;
  17122. /**
  17123. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17124. * @returns the scaled intensity in intensity mode unit
  17125. */
  17126. getScaledIntensity(): number;
  17127. /**
  17128. * Returns a new Light object, named "name", from the current one.
  17129. * @param name The name of the cloned light
  17130. * @returns the new created light
  17131. */
  17132. clone(name: string): Nullable<Light>;
  17133. /**
  17134. * Serializes the current light into a Serialization object.
  17135. * @returns the serialized object.
  17136. */
  17137. serialize(): any;
  17138. /**
  17139. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17140. * This new light is named "name" and added to the passed scene.
  17141. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17142. * @param name The friendly name of the light
  17143. * @param scene The scene the new light will belong to
  17144. * @returns the constructor function
  17145. */
  17146. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17147. /**
  17148. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17149. * @param parsedLight The JSON representation of the light
  17150. * @param scene The scene to create the parsed light in
  17151. * @returns the created light after parsing
  17152. */
  17153. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17154. private _hookArrayForExcluded;
  17155. private _hookArrayForIncludedOnly;
  17156. private _resyncMeshes;
  17157. /**
  17158. * Forces the meshes to update their light related information in their rendering used effects
  17159. * @hidden Internal Use Only
  17160. */
  17161. _markMeshesAsLightDirty(): void;
  17162. /**
  17163. * Recomputes the cached photometric scale if needed.
  17164. */
  17165. private _computePhotometricScale;
  17166. /**
  17167. * Returns the Photometric Scale according to the light type and intensity mode.
  17168. */
  17169. private _getPhotometricScale;
  17170. /**
  17171. * Reorder the light in the scene according to their defined priority.
  17172. * @hidden Internal Use Only
  17173. */
  17174. _reorderLightsInScene(): void;
  17175. /**
  17176. * Prepares the list of defines specific to the light type.
  17177. * @param defines the list of defines
  17178. * @param lightIndex defines the index of the light for the effect
  17179. */
  17180. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17181. }
  17182. }
  17183. declare module BABYLON {
  17184. /**
  17185. * Interface used to define Action
  17186. */
  17187. export interface IAction {
  17188. /**
  17189. * Trigger for the action
  17190. */
  17191. trigger: number;
  17192. /** Options of the trigger */
  17193. triggerOptions: any;
  17194. /**
  17195. * Gets the trigger parameters
  17196. * @returns the trigger parameters
  17197. */
  17198. getTriggerParameter(): any;
  17199. /**
  17200. * Internal only - executes current action event
  17201. * @hidden
  17202. */
  17203. _executeCurrent(evt?: ActionEvent): void;
  17204. /**
  17205. * Serialize placeholder for child classes
  17206. * @param parent of child
  17207. * @returns the serialized object
  17208. */
  17209. serialize(parent: any): any;
  17210. /**
  17211. * Internal only
  17212. * @hidden
  17213. */
  17214. _prepare(): void;
  17215. /**
  17216. * Internal only - manager for action
  17217. * @hidden
  17218. */
  17219. _actionManager: AbstractActionManager;
  17220. /**
  17221. * Adds action to chain of actions, may be a DoNothingAction
  17222. * @param action defines the next action to execute
  17223. * @returns The action passed in
  17224. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17225. */
  17226. then(action: IAction): IAction;
  17227. }
  17228. /**
  17229. * The action to be carried out following a trigger
  17230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17231. */
  17232. export class Action implements IAction {
  17233. /** the trigger, with or without parameters, for the action */
  17234. triggerOptions: any;
  17235. /**
  17236. * Trigger for the action
  17237. */
  17238. trigger: number;
  17239. /**
  17240. * Internal only - manager for action
  17241. * @hidden
  17242. */
  17243. _actionManager: ActionManager;
  17244. private _nextActiveAction;
  17245. private _child;
  17246. private _condition?;
  17247. private _triggerParameter;
  17248. /**
  17249. * An event triggered prior to action being executed.
  17250. */
  17251. onBeforeExecuteObservable: Observable<Action>;
  17252. /**
  17253. * Creates a new Action
  17254. * @param triggerOptions the trigger, with or without parameters, for the action
  17255. * @param condition an optional determinant of action
  17256. */
  17257. constructor(
  17258. /** the trigger, with or without parameters, for the action */
  17259. triggerOptions: any, condition?: Condition);
  17260. /**
  17261. * Internal only
  17262. * @hidden
  17263. */
  17264. _prepare(): void;
  17265. /**
  17266. * Gets the trigger parameters
  17267. * @returns the trigger parameters
  17268. */
  17269. getTriggerParameter(): any;
  17270. /**
  17271. * Internal only - executes current action event
  17272. * @hidden
  17273. */
  17274. _executeCurrent(evt?: ActionEvent): void;
  17275. /**
  17276. * Execute placeholder for child classes
  17277. * @param evt optional action event
  17278. */
  17279. execute(evt?: ActionEvent): void;
  17280. /**
  17281. * Skips to next active action
  17282. */
  17283. skipToNextActiveAction(): void;
  17284. /**
  17285. * Adds action to chain of actions, may be a DoNothingAction
  17286. * @param action defines the next action to execute
  17287. * @returns The action passed in
  17288. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17289. */
  17290. then(action: Action): Action;
  17291. /**
  17292. * Internal only
  17293. * @hidden
  17294. */
  17295. _getProperty(propertyPath: string): string;
  17296. /**
  17297. * Internal only
  17298. * @hidden
  17299. */
  17300. _getEffectiveTarget(target: any, propertyPath: string): any;
  17301. /**
  17302. * Serialize placeholder for child classes
  17303. * @param parent of child
  17304. * @returns the serialized object
  17305. */
  17306. serialize(parent: any): any;
  17307. /**
  17308. * Internal only called by serialize
  17309. * @hidden
  17310. */
  17311. protected _serialize(serializedAction: any, parent?: any): any;
  17312. /**
  17313. * Internal only
  17314. * @hidden
  17315. */
  17316. static _SerializeValueAsString: (value: any) => string;
  17317. /**
  17318. * Internal only
  17319. * @hidden
  17320. */
  17321. static _GetTargetProperty: (target: Node | Scene) => {
  17322. name: string;
  17323. targetType: string;
  17324. value: string;
  17325. };
  17326. }
  17327. }
  17328. declare module BABYLON {
  17329. /**
  17330. * A Condition applied to an Action
  17331. */
  17332. export class Condition {
  17333. /**
  17334. * Internal only - manager for action
  17335. * @hidden
  17336. */
  17337. _actionManager: ActionManager;
  17338. /**
  17339. * Internal only
  17340. * @hidden
  17341. */
  17342. _evaluationId: number;
  17343. /**
  17344. * Internal only
  17345. * @hidden
  17346. */
  17347. _currentResult: boolean;
  17348. /**
  17349. * Creates a new Condition
  17350. * @param actionManager the manager of the action the condition is applied to
  17351. */
  17352. constructor(actionManager: ActionManager);
  17353. /**
  17354. * Check if the current condition is valid
  17355. * @returns a boolean
  17356. */
  17357. isValid(): boolean;
  17358. /**
  17359. * Internal only
  17360. * @hidden
  17361. */
  17362. _getProperty(propertyPath: string): string;
  17363. /**
  17364. * Internal only
  17365. * @hidden
  17366. */
  17367. _getEffectiveTarget(target: any, propertyPath: string): any;
  17368. /**
  17369. * Serialize placeholder for child classes
  17370. * @returns the serialized object
  17371. */
  17372. serialize(): any;
  17373. /**
  17374. * Internal only
  17375. * @hidden
  17376. */
  17377. protected _serialize(serializedCondition: any): any;
  17378. }
  17379. /**
  17380. * Defines specific conditional operators as extensions of Condition
  17381. */
  17382. export class ValueCondition extends Condition {
  17383. /** path to specify the property of the target the conditional operator uses */
  17384. propertyPath: string;
  17385. /** the value compared by the conditional operator against the current value of the property */
  17386. value: any;
  17387. /** the conditional operator, default ValueCondition.IsEqual */
  17388. operator: number;
  17389. /**
  17390. * Internal only
  17391. * @hidden
  17392. */
  17393. private static _IsEqual;
  17394. /**
  17395. * Internal only
  17396. * @hidden
  17397. */
  17398. private static _IsDifferent;
  17399. /**
  17400. * Internal only
  17401. * @hidden
  17402. */
  17403. private static _IsGreater;
  17404. /**
  17405. * Internal only
  17406. * @hidden
  17407. */
  17408. private static _IsLesser;
  17409. /**
  17410. * returns the number for IsEqual
  17411. */
  17412. static get IsEqual(): number;
  17413. /**
  17414. * Returns the number for IsDifferent
  17415. */
  17416. static get IsDifferent(): number;
  17417. /**
  17418. * Returns the number for IsGreater
  17419. */
  17420. static get IsGreater(): number;
  17421. /**
  17422. * Returns the number for IsLesser
  17423. */
  17424. static get IsLesser(): number;
  17425. /**
  17426. * Internal only The action manager for the condition
  17427. * @hidden
  17428. */
  17429. _actionManager: ActionManager;
  17430. /**
  17431. * Internal only
  17432. * @hidden
  17433. */
  17434. private _target;
  17435. /**
  17436. * Internal only
  17437. * @hidden
  17438. */
  17439. private _effectiveTarget;
  17440. /**
  17441. * Internal only
  17442. * @hidden
  17443. */
  17444. private _property;
  17445. /**
  17446. * Creates a new ValueCondition
  17447. * @param actionManager manager for the action the condition applies to
  17448. * @param target for the action
  17449. * @param propertyPath path to specify the property of the target the conditional operator uses
  17450. * @param value the value compared by the conditional operator against the current value of the property
  17451. * @param operator the conditional operator, default ValueCondition.IsEqual
  17452. */
  17453. constructor(actionManager: ActionManager, target: any,
  17454. /** path to specify the property of the target the conditional operator uses */
  17455. propertyPath: string,
  17456. /** the value compared by the conditional operator against the current value of the property */
  17457. value: any,
  17458. /** the conditional operator, default ValueCondition.IsEqual */
  17459. operator?: number);
  17460. /**
  17461. * Compares the given value with the property value for the specified conditional operator
  17462. * @returns the result of the comparison
  17463. */
  17464. isValid(): boolean;
  17465. /**
  17466. * Serialize the ValueCondition into a JSON compatible object
  17467. * @returns serialization object
  17468. */
  17469. serialize(): any;
  17470. /**
  17471. * Gets the name of the conditional operator for the ValueCondition
  17472. * @param operator the conditional operator
  17473. * @returns the name
  17474. */
  17475. static GetOperatorName(operator: number): string;
  17476. }
  17477. /**
  17478. * Defines a predicate condition as an extension of Condition
  17479. */
  17480. export class PredicateCondition extends Condition {
  17481. /** defines the predicate function used to validate the condition */
  17482. predicate: () => boolean;
  17483. /**
  17484. * Internal only - manager for action
  17485. * @hidden
  17486. */
  17487. _actionManager: ActionManager;
  17488. /**
  17489. * Creates a new PredicateCondition
  17490. * @param actionManager manager for the action the condition applies to
  17491. * @param predicate defines the predicate function used to validate the condition
  17492. */
  17493. constructor(actionManager: ActionManager,
  17494. /** defines the predicate function used to validate the condition */
  17495. predicate: () => boolean);
  17496. /**
  17497. * @returns the validity of the predicate condition
  17498. */
  17499. isValid(): boolean;
  17500. }
  17501. /**
  17502. * Defines a state condition as an extension of Condition
  17503. */
  17504. export class StateCondition extends Condition {
  17505. /** Value to compare with target state */
  17506. value: string;
  17507. /**
  17508. * Internal only - manager for action
  17509. * @hidden
  17510. */
  17511. _actionManager: ActionManager;
  17512. /**
  17513. * Internal only
  17514. * @hidden
  17515. */
  17516. private _target;
  17517. /**
  17518. * Creates a new StateCondition
  17519. * @param actionManager manager for the action the condition applies to
  17520. * @param target of the condition
  17521. * @param value to compare with target state
  17522. */
  17523. constructor(actionManager: ActionManager, target: any,
  17524. /** Value to compare with target state */
  17525. value: string);
  17526. /**
  17527. * Gets a boolean indicating if the current condition is met
  17528. * @returns the validity of the state
  17529. */
  17530. isValid(): boolean;
  17531. /**
  17532. * Serialize the StateCondition into a JSON compatible object
  17533. * @returns serialization object
  17534. */
  17535. serialize(): any;
  17536. }
  17537. }
  17538. declare module BABYLON {
  17539. /**
  17540. * This defines an action responsible to toggle a boolean once triggered.
  17541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17542. */
  17543. export class SwitchBooleanAction extends Action {
  17544. /**
  17545. * The path to the boolean property in the target object
  17546. */
  17547. propertyPath: string;
  17548. private _target;
  17549. private _effectiveTarget;
  17550. private _property;
  17551. /**
  17552. * Instantiate the action
  17553. * @param triggerOptions defines the trigger options
  17554. * @param target defines the object containing the boolean
  17555. * @param propertyPath defines the path to the boolean property in the target object
  17556. * @param condition defines the trigger related conditions
  17557. */
  17558. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17559. /** @hidden */
  17560. _prepare(): void;
  17561. /**
  17562. * Execute the action toggle the boolean value.
  17563. */
  17564. execute(): void;
  17565. /**
  17566. * Serializes the actions and its related information.
  17567. * @param parent defines the object to serialize in
  17568. * @returns the serialized object
  17569. */
  17570. serialize(parent: any): any;
  17571. }
  17572. /**
  17573. * This defines an action responsible to set a the state field of the target
  17574. * to a desired value once triggered.
  17575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17576. */
  17577. export class SetStateAction extends Action {
  17578. /**
  17579. * The value to store in the state field.
  17580. */
  17581. value: string;
  17582. private _target;
  17583. /**
  17584. * Instantiate the action
  17585. * @param triggerOptions defines the trigger options
  17586. * @param target defines the object containing the state property
  17587. * @param value defines the value to store in the state field
  17588. * @param condition defines the trigger related conditions
  17589. */
  17590. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17591. /**
  17592. * Execute the action and store the value on the target state property.
  17593. */
  17594. execute(): void;
  17595. /**
  17596. * Serializes the actions and its related information.
  17597. * @param parent defines the object to serialize in
  17598. * @returns the serialized object
  17599. */
  17600. serialize(parent: any): any;
  17601. }
  17602. /**
  17603. * This defines an action responsible to set a property of the target
  17604. * to a desired value once triggered.
  17605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17606. */
  17607. export class SetValueAction extends Action {
  17608. /**
  17609. * The path of the property to set in the target.
  17610. */
  17611. propertyPath: string;
  17612. /**
  17613. * The value to set in the property
  17614. */
  17615. value: any;
  17616. private _target;
  17617. private _effectiveTarget;
  17618. private _property;
  17619. /**
  17620. * Instantiate the action
  17621. * @param triggerOptions defines the trigger options
  17622. * @param target defines the object containing the property
  17623. * @param propertyPath defines the path of the property to set in the target
  17624. * @param value defines the value to set in the property
  17625. * @param condition defines the trigger related conditions
  17626. */
  17627. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17628. /** @hidden */
  17629. _prepare(): void;
  17630. /**
  17631. * Execute the action and set the targetted property to the desired value.
  17632. */
  17633. execute(): void;
  17634. /**
  17635. * Serializes the actions and its related information.
  17636. * @param parent defines the object to serialize in
  17637. * @returns the serialized object
  17638. */
  17639. serialize(parent: any): any;
  17640. }
  17641. /**
  17642. * This defines an action responsible to increment the target value
  17643. * to a desired value once triggered.
  17644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17645. */
  17646. export class IncrementValueAction extends Action {
  17647. /**
  17648. * The path of the property to increment in the target.
  17649. */
  17650. propertyPath: string;
  17651. /**
  17652. * The value we should increment the property by.
  17653. */
  17654. value: any;
  17655. private _target;
  17656. private _effectiveTarget;
  17657. private _property;
  17658. /**
  17659. * Instantiate the action
  17660. * @param triggerOptions defines the trigger options
  17661. * @param target defines the object containing the property
  17662. * @param propertyPath defines the path of the property to increment in the target
  17663. * @param value defines the value value we should increment the property by
  17664. * @param condition defines the trigger related conditions
  17665. */
  17666. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17667. /** @hidden */
  17668. _prepare(): void;
  17669. /**
  17670. * Execute the action and increment the target of the value amount.
  17671. */
  17672. execute(): void;
  17673. /**
  17674. * Serializes the actions and its related information.
  17675. * @param parent defines the object to serialize in
  17676. * @returns the serialized object
  17677. */
  17678. serialize(parent: any): any;
  17679. }
  17680. /**
  17681. * This defines an action responsible to start an animation once triggered.
  17682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17683. */
  17684. export class PlayAnimationAction extends Action {
  17685. /**
  17686. * Where the animation should start (animation frame)
  17687. */
  17688. from: number;
  17689. /**
  17690. * Where the animation should stop (animation frame)
  17691. */
  17692. to: number;
  17693. /**
  17694. * Define if the animation should loop or stop after the first play.
  17695. */
  17696. loop?: boolean;
  17697. private _target;
  17698. /**
  17699. * Instantiate the action
  17700. * @param triggerOptions defines the trigger options
  17701. * @param target defines the target animation or animation name
  17702. * @param from defines from where the animation should start (animation frame)
  17703. * @param end defines where the animation should stop (animation frame)
  17704. * @param loop defines if the animation should loop or stop after the first play
  17705. * @param condition defines the trigger related conditions
  17706. */
  17707. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17708. /** @hidden */
  17709. _prepare(): void;
  17710. /**
  17711. * Execute the action and play the animation.
  17712. */
  17713. execute(): void;
  17714. /**
  17715. * Serializes the actions and its related information.
  17716. * @param parent defines the object to serialize in
  17717. * @returns the serialized object
  17718. */
  17719. serialize(parent: any): any;
  17720. }
  17721. /**
  17722. * This defines an action responsible to stop an animation once triggered.
  17723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17724. */
  17725. export class StopAnimationAction extends Action {
  17726. private _target;
  17727. /**
  17728. * Instantiate the action
  17729. * @param triggerOptions defines the trigger options
  17730. * @param target defines the target animation or animation name
  17731. * @param condition defines the trigger related conditions
  17732. */
  17733. constructor(triggerOptions: any, target: any, condition?: Condition);
  17734. /** @hidden */
  17735. _prepare(): void;
  17736. /**
  17737. * Execute the action and stop the animation.
  17738. */
  17739. execute(): void;
  17740. /**
  17741. * Serializes the actions and its related information.
  17742. * @param parent defines the object to serialize in
  17743. * @returns the serialized object
  17744. */
  17745. serialize(parent: any): any;
  17746. }
  17747. /**
  17748. * This defines an action responsible that does nothing once triggered.
  17749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17750. */
  17751. export class DoNothingAction extends Action {
  17752. /**
  17753. * Instantiate the action
  17754. * @param triggerOptions defines the trigger options
  17755. * @param condition defines the trigger related conditions
  17756. */
  17757. constructor(triggerOptions?: any, condition?: Condition);
  17758. /**
  17759. * Execute the action and do nothing.
  17760. */
  17761. execute(): void;
  17762. /**
  17763. * Serializes the actions and its related information.
  17764. * @param parent defines the object to serialize in
  17765. * @returns the serialized object
  17766. */
  17767. serialize(parent: any): any;
  17768. }
  17769. /**
  17770. * This defines an action responsible to trigger several actions once triggered.
  17771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17772. */
  17773. export class CombineAction extends Action {
  17774. /**
  17775. * The list of aggregated animations to run.
  17776. */
  17777. children: Action[];
  17778. /**
  17779. * Instantiate the action
  17780. * @param triggerOptions defines the trigger options
  17781. * @param children defines the list of aggregated animations to run
  17782. * @param condition defines the trigger related conditions
  17783. */
  17784. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17785. /** @hidden */
  17786. _prepare(): void;
  17787. /**
  17788. * Execute the action and executes all the aggregated actions.
  17789. */
  17790. execute(evt: ActionEvent): void;
  17791. /**
  17792. * Serializes the actions and its related information.
  17793. * @param parent defines the object to serialize in
  17794. * @returns the serialized object
  17795. */
  17796. serialize(parent: any): any;
  17797. }
  17798. /**
  17799. * This defines an action responsible to run code (external event) once triggered.
  17800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17801. */
  17802. export class ExecuteCodeAction extends Action {
  17803. /**
  17804. * The callback function to run.
  17805. */
  17806. func: (evt: ActionEvent) => void;
  17807. /**
  17808. * Instantiate the action
  17809. * @param triggerOptions defines the trigger options
  17810. * @param func defines the callback function to run
  17811. * @param condition defines the trigger related conditions
  17812. */
  17813. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17814. /**
  17815. * Execute the action and run the attached code.
  17816. */
  17817. execute(evt: ActionEvent): void;
  17818. }
  17819. /**
  17820. * This defines an action responsible to set the parent property of the target once triggered.
  17821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17822. */
  17823. export class SetParentAction extends Action {
  17824. private _parent;
  17825. private _target;
  17826. /**
  17827. * Instantiate the action
  17828. * @param triggerOptions defines the trigger options
  17829. * @param target defines the target containing the parent property
  17830. * @param parent defines from where the animation should start (animation frame)
  17831. * @param condition defines the trigger related conditions
  17832. */
  17833. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17834. /** @hidden */
  17835. _prepare(): void;
  17836. /**
  17837. * Execute the action and set the parent property.
  17838. */
  17839. execute(): void;
  17840. /**
  17841. * Serializes the actions and its related information.
  17842. * @param parent defines the object to serialize in
  17843. * @returns the serialized object
  17844. */
  17845. serialize(parent: any): any;
  17846. }
  17847. }
  17848. declare module BABYLON {
  17849. /**
  17850. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17851. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17853. */
  17854. export class ActionManager extends AbstractActionManager {
  17855. /**
  17856. * Nothing
  17857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17858. */
  17859. static readonly NothingTrigger: number;
  17860. /**
  17861. * On pick
  17862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17863. */
  17864. static readonly OnPickTrigger: number;
  17865. /**
  17866. * On left pick
  17867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17868. */
  17869. static readonly OnLeftPickTrigger: number;
  17870. /**
  17871. * On right pick
  17872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17873. */
  17874. static readonly OnRightPickTrigger: number;
  17875. /**
  17876. * On center pick
  17877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17878. */
  17879. static readonly OnCenterPickTrigger: number;
  17880. /**
  17881. * On pick down
  17882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17883. */
  17884. static readonly OnPickDownTrigger: number;
  17885. /**
  17886. * On double pick
  17887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17888. */
  17889. static readonly OnDoublePickTrigger: number;
  17890. /**
  17891. * On pick up
  17892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17893. */
  17894. static readonly OnPickUpTrigger: number;
  17895. /**
  17896. * On pick out.
  17897. * This trigger will only be raised if you also declared a OnPickDown
  17898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17899. */
  17900. static readonly OnPickOutTrigger: number;
  17901. /**
  17902. * On long press
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17904. */
  17905. static readonly OnLongPressTrigger: number;
  17906. /**
  17907. * On pointer over
  17908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17909. */
  17910. static readonly OnPointerOverTrigger: number;
  17911. /**
  17912. * On pointer out
  17913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17914. */
  17915. static readonly OnPointerOutTrigger: number;
  17916. /**
  17917. * On every frame
  17918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17919. */
  17920. static readonly OnEveryFrameTrigger: number;
  17921. /**
  17922. * On intersection enter
  17923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17924. */
  17925. static readonly OnIntersectionEnterTrigger: number;
  17926. /**
  17927. * On intersection exit
  17928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17929. */
  17930. static readonly OnIntersectionExitTrigger: number;
  17931. /**
  17932. * On key down
  17933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17934. */
  17935. static readonly OnKeyDownTrigger: number;
  17936. /**
  17937. * On key up
  17938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17939. */
  17940. static readonly OnKeyUpTrigger: number;
  17941. private _scene;
  17942. /**
  17943. * Creates a new action manager
  17944. * @param scene defines the hosting scene
  17945. */
  17946. constructor(scene: Scene);
  17947. /**
  17948. * Releases all associated resources
  17949. */
  17950. dispose(): void;
  17951. /**
  17952. * Gets hosting scene
  17953. * @returns the hosting scene
  17954. */
  17955. getScene(): Scene;
  17956. /**
  17957. * Does this action manager handles actions of any of the given triggers
  17958. * @param triggers defines the triggers to be tested
  17959. * @return a boolean indicating whether one (or more) of the triggers is handled
  17960. */
  17961. hasSpecificTriggers(triggers: number[]): boolean;
  17962. /**
  17963. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17964. * speed.
  17965. * @param triggerA defines the trigger to be tested
  17966. * @param triggerB defines the trigger to be tested
  17967. * @return a boolean indicating whether one (or more) of the triggers is handled
  17968. */
  17969. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17970. /**
  17971. * Does this action manager handles actions of a given trigger
  17972. * @param trigger defines the trigger to be tested
  17973. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17974. * @return whether the trigger is handled
  17975. */
  17976. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17977. /**
  17978. * Does this action manager has pointer triggers
  17979. */
  17980. get hasPointerTriggers(): boolean;
  17981. /**
  17982. * Does this action manager has pick triggers
  17983. */
  17984. get hasPickTriggers(): boolean;
  17985. /**
  17986. * Registers an action to this action manager
  17987. * @param action defines the action to be registered
  17988. * @return the action amended (prepared) after registration
  17989. */
  17990. registerAction(action: IAction): Nullable<IAction>;
  17991. /**
  17992. * Unregisters an action to this action manager
  17993. * @param action defines the action to be unregistered
  17994. * @return a boolean indicating whether the action has been unregistered
  17995. */
  17996. unregisterAction(action: IAction): Boolean;
  17997. /**
  17998. * Process a specific trigger
  17999. * @param trigger defines the trigger to process
  18000. * @param evt defines the event details to be processed
  18001. */
  18002. processTrigger(trigger: number, evt?: IActionEvent): void;
  18003. /** @hidden */
  18004. _getEffectiveTarget(target: any, propertyPath: string): any;
  18005. /** @hidden */
  18006. _getProperty(propertyPath: string): string;
  18007. /**
  18008. * Serialize this manager to a JSON object
  18009. * @param name defines the property name to store this manager
  18010. * @returns a JSON representation of this manager
  18011. */
  18012. serialize(name: string): any;
  18013. /**
  18014. * Creates a new ActionManager from a JSON data
  18015. * @param parsedActions defines the JSON data to read from
  18016. * @param object defines the hosting mesh
  18017. * @param scene defines the hosting scene
  18018. */
  18019. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18020. /**
  18021. * Get a trigger name by index
  18022. * @param trigger defines the trigger index
  18023. * @returns a trigger name
  18024. */
  18025. static GetTriggerName(trigger: number): string;
  18026. }
  18027. }
  18028. declare module BABYLON {
  18029. /**
  18030. * Class used to represent a sprite
  18031. * @see http://doc.babylonjs.com/babylon101/sprites
  18032. */
  18033. export class Sprite {
  18034. /** defines the name */
  18035. name: string;
  18036. /** Gets or sets the current world position */
  18037. position: Vector3;
  18038. /** Gets or sets the main color */
  18039. color: Color4;
  18040. /** Gets or sets the width */
  18041. width: number;
  18042. /** Gets or sets the height */
  18043. height: number;
  18044. /** Gets or sets rotation angle */
  18045. angle: number;
  18046. /** Gets or sets the cell index in the sprite sheet */
  18047. cellIndex: number;
  18048. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18049. cellRef: string;
  18050. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18051. invertU: number;
  18052. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18053. invertV: number;
  18054. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18055. disposeWhenFinishedAnimating: boolean;
  18056. /** Gets the list of attached animations */
  18057. animations: Animation[];
  18058. /** Gets or sets a boolean indicating if the sprite can be picked */
  18059. isPickable: boolean;
  18060. /**
  18061. * Gets or sets the associated action manager
  18062. */
  18063. actionManager: Nullable<ActionManager>;
  18064. private _animationStarted;
  18065. private _loopAnimation;
  18066. private _fromIndex;
  18067. private _toIndex;
  18068. private _delay;
  18069. private _direction;
  18070. private _manager;
  18071. private _time;
  18072. private _onAnimationEnd;
  18073. /**
  18074. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18075. */
  18076. isVisible: boolean;
  18077. /**
  18078. * Gets or sets the sprite size
  18079. */
  18080. get size(): number;
  18081. set size(value: number);
  18082. /**
  18083. * Creates a new Sprite
  18084. * @param name defines the name
  18085. * @param manager defines the manager
  18086. */
  18087. constructor(
  18088. /** defines the name */
  18089. name: string, manager: ISpriteManager);
  18090. /**
  18091. * Starts an animation
  18092. * @param from defines the initial key
  18093. * @param to defines the end key
  18094. * @param loop defines if the animation must loop
  18095. * @param delay defines the start delay (in ms)
  18096. * @param onAnimationEnd defines a callback to call when animation ends
  18097. */
  18098. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18099. /** Stops current animation (if any) */
  18100. stopAnimation(): void;
  18101. /** @hidden */
  18102. _animate(deltaTime: number): void;
  18103. /** Release associated resources */
  18104. dispose(): void;
  18105. }
  18106. }
  18107. declare module BABYLON {
  18108. /**
  18109. * Information about the result of picking within a scene
  18110. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18111. */
  18112. export class PickingInfo {
  18113. /** @hidden */
  18114. _pickingUnavailable: boolean;
  18115. /**
  18116. * If the pick collided with an object
  18117. */
  18118. hit: boolean;
  18119. /**
  18120. * Distance away where the pick collided
  18121. */
  18122. distance: number;
  18123. /**
  18124. * The location of pick collision
  18125. */
  18126. pickedPoint: Nullable<Vector3>;
  18127. /**
  18128. * The mesh corresponding the the pick collision
  18129. */
  18130. pickedMesh: Nullable<AbstractMesh>;
  18131. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18132. bu: number;
  18133. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18134. bv: number;
  18135. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18136. faceId: number;
  18137. /** Id of the the submesh that was picked */
  18138. subMeshId: number;
  18139. /** If a sprite was picked, this will be the sprite the pick collided with */
  18140. pickedSprite: Nullable<Sprite>;
  18141. /**
  18142. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18143. */
  18144. originMesh: Nullable<AbstractMesh>;
  18145. /**
  18146. * The ray that was used to perform the picking.
  18147. */
  18148. ray: Nullable<Ray>;
  18149. /**
  18150. * Gets the normal correspodning to the face the pick collided with
  18151. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18152. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18153. * @returns The normal correspodning to the face the pick collided with
  18154. */
  18155. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18156. /**
  18157. * Gets the texture coordinates of where the pick occured
  18158. * @returns the vector containing the coordnates of the texture
  18159. */
  18160. getTextureCoordinates(): Nullable<Vector2>;
  18161. }
  18162. }
  18163. declare module BABYLON {
  18164. /**
  18165. * Gather the list of pointer event types as constants.
  18166. */
  18167. export class PointerEventTypes {
  18168. /**
  18169. * 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.
  18170. */
  18171. static readonly POINTERDOWN: number;
  18172. /**
  18173. * The pointerup event is fired when a pointer is no longer active.
  18174. */
  18175. static readonly POINTERUP: number;
  18176. /**
  18177. * The pointermove event is fired when a pointer changes coordinates.
  18178. */
  18179. static readonly POINTERMOVE: number;
  18180. /**
  18181. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18182. */
  18183. static readonly POINTERWHEEL: number;
  18184. /**
  18185. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18186. */
  18187. static readonly POINTERPICK: number;
  18188. /**
  18189. * The pointertap event is fired when a the object has been touched and released without drag.
  18190. */
  18191. static readonly POINTERTAP: number;
  18192. /**
  18193. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18194. */
  18195. static readonly POINTERDOUBLETAP: number;
  18196. }
  18197. /**
  18198. * Base class of pointer info types.
  18199. */
  18200. export class PointerInfoBase {
  18201. /**
  18202. * Defines the type of event (PointerEventTypes)
  18203. */
  18204. type: number;
  18205. /**
  18206. * Defines the related dom event
  18207. */
  18208. event: PointerEvent | MouseWheelEvent;
  18209. /**
  18210. * Instantiates the base class of pointers info.
  18211. * @param type Defines the type of event (PointerEventTypes)
  18212. * @param event Defines the related dom event
  18213. */
  18214. constructor(
  18215. /**
  18216. * Defines the type of event (PointerEventTypes)
  18217. */
  18218. type: number,
  18219. /**
  18220. * Defines the related dom event
  18221. */
  18222. event: PointerEvent | MouseWheelEvent);
  18223. }
  18224. /**
  18225. * This class is used to store pointer related info for the onPrePointerObservable event.
  18226. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18227. */
  18228. export class PointerInfoPre extends PointerInfoBase {
  18229. /**
  18230. * Ray from a pointer if availible (eg. 6dof controller)
  18231. */
  18232. ray: Nullable<Ray>;
  18233. /**
  18234. * Defines the local position of the pointer on the canvas.
  18235. */
  18236. localPosition: Vector2;
  18237. /**
  18238. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18239. */
  18240. skipOnPointerObservable: boolean;
  18241. /**
  18242. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18243. * @param type Defines the type of event (PointerEventTypes)
  18244. * @param event Defines the related dom event
  18245. * @param localX Defines the local x coordinates of the pointer when the event occured
  18246. * @param localY Defines the local y coordinates of the pointer when the event occured
  18247. */
  18248. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18249. }
  18250. /**
  18251. * This type contains all the data related to a pointer event in Babylon.js.
  18252. * 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.
  18253. */
  18254. export class PointerInfo extends PointerInfoBase {
  18255. /**
  18256. * Defines the picking info associated to the info (if any)\
  18257. */
  18258. pickInfo: Nullable<PickingInfo>;
  18259. /**
  18260. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18261. * @param type Defines the type of event (PointerEventTypes)
  18262. * @param event Defines the related dom event
  18263. * @param pickInfo Defines the picking info associated to the info (if any)\
  18264. */
  18265. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18266. /**
  18267. * Defines the picking info associated to the info (if any)\
  18268. */
  18269. pickInfo: Nullable<PickingInfo>);
  18270. }
  18271. /**
  18272. * Data relating to a touch event on the screen.
  18273. */
  18274. export interface PointerTouch {
  18275. /**
  18276. * X coordinate of touch.
  18277. */
  18278. x: number;
  18279. /**
  18280. * Y coordinate of touch.
  18281. */
  18282. y: number;
  18283. /**
  18284. * Id of touch. Unique for each finger.
  18285. */
  18286. pointerId: number;
  18287. /**
  18288. * Event type passed from DOM.
  18289. */
  18290. type: any;
  18291. }
  18292. }
  18293. declare module BABYLON {
  18294. /**
  18295. * Manage the mouse inputs to control the movement of a free camera.
  18296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18297. */
  18298. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18299. /**
  18300. * Define if touch is enabled in the mouse input
  18301. */
  18302. touchEnabled: boolean;
  18303. /**
  18304. * Defines the camera the input is attached to.
  18305. */
  18306. camera: FreeCamera;
  18307. /**
  18308. * Defines the buttons associated with the input to handle camera move.
  18309. */
  18310. buttons: number[];
  18311. /**
  18312. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18313. */
  18314. angularSensibility: number;
  18315. private _pointerInput;
  18316. private _onMouseMove;
  18317. private _observer;
  18318. private previousPosition;
  18319. /**
  18320. * Observable for when a pointer move event occurs containing the move offset
  18321. */
  18322. onPointerMovedObservable: Observable<{
  18323. offsetX: number;
  18324. offsetY: number;
  18325. }>;
  18326. /**
  18327. * @hidden
  18328. * If the camera should be rotated automatically based on pointer movement
  18329. */
  18330. _allowCameraRotation: boolean;
  18331. /**
  18332. * Manage the mouse inputs to control the movement of a free camera.
  18333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18334. * @param touchEnabled Defines if touch is enabled or not
  18335. */
  18336. constructor(
  18337. /**
  18338. * Define if touch is enabled in the mouse input
  18339. */
  18340. touchEnabled?: boolean);
  18341. /**
  18342. * Attach the input controls to a specific dom element to get the input from.
  18343. * @param element Defines the element the controls should be listened from
  18344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18345. */
  18346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18347. /**
  18348. * Called on JS contextmenu event.
  18349. * Override this method to provide functionality.
  18350. */
  18351. protected onContextMenu(evt: PointerEvent): void;
  18352. /**
  18353. * Detach the current controls from the specified dom element.
  18354. * @param element Defines the element to stop listening the inputs from
  18355. */
  18356. detachControl(element: Nullable<HTMLElement>): void;
  18357. /**
  18358. * Gets the class name of the current intput.
  18359. * @returns the class name
  18360. */
  18361. getClassName(): string;
  18362. /**
  18363. * Get the friendly name associated with the input class.
  18364. * @returns the input friendly name
  18365. */
  18366. getSimpleName(): string;
  18367. }
  18368. }
  18369. declare module BABYLON {
  18370. /**
  18371. * Manage the touch inputs to control the movement of a free camera.
  18372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18373. */
  18374. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18375. /**
  18376. * Defines the camera the input is attached to.
  18377. */
  18378. camera: FreeCamera;
  18379. /**
  18380. * Defines the touch sensibility for rotation.
  18381. * The higher the faster.
  18382. */
  18383. touchAngularSensibility: number;
  18384. /**
  18385. * Defines the touch sensibility for move.
  18386. * The higher the faster.
  18387. */
  18388. touchMoveSensibility: number;
  18389. private _offsetX;
  18390. private _offsetY;
  18391. private _pointerPressed;
  18392. private _pointerInput;
  18393. private _observer;
  18394. private _onLostFocus;
  18395. /**
  18396. * Attach the input controls to a specific dom element to get the input from.
  18397. * @param element Defines the element the controls should be listened from
  18398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18399. */
  18400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18401. /**
  18402. * Detach the current controls from the specified dom element.
  18403. * @param element Defines the element to stop listening the inputs from
  18404. */
  18405. detachControl(element: Nullable<HTMLElement>): void;
  18406. /**
  18407. * Update the current camera state depending on the inputs that have been used this frame.
  18408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18409. */
  18410. checkInputs(): void;
  18411. /**
  18412. * Gets the class name of the current intput.
  18413. * @returns the class name
  18414. */
  18415. getClassName(): string;
  18416. /**
  18417. * Get the friendly name associated with the input class.
  18418. * @returns the input friendly name
  18419. */
  18420. getSimpleName(): string;
  18421. }
  18422. }
  18423. declare module BABYLON {
  18424. /**
  18425. * Default Inputs manager for the FreeCamera.
  18426. * It groups all the default supported inputs for ease of use.
  18427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18428. */
  18429. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18430. /**
  18431. * @hidden
  18432. */
  18433. _mouseInput: Nullable<FreeCameraMouseInput>;
  18434. /**
  18435. * Instantiates a new FreeCameraInputsManager.
  18436. * @param camera Defines the camera the inputs belong to
  18437. */
  18438. constructor(camera: FreeCamera);
  18439. /**
  18440. * Add keyboard input support to the input manager.
  18441. * @returns the current input manager
  18442. */
  18443. addKeyboard(): FreeCameraInputsManager;
  18444. /**
  18445. * Add mouse input support to the input manager.
  18446. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18447. * @returns the current input manager
  18448. */
  18449. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18450. /**
  18451. * Removes the mouse input support from the manager
  18452. * @returns the current input manager
  18453. */
  18454. removeMouse(): FreeCameraInputsManager;
  18455. /**
  18456. * Add touch input support to the input manager.
  18457. * @returns the current input manager
  18458. */
  18459. addTouch(): FreeCameraInputsManager;
  18460. /**
  18461. * Remove all attached input methods from a camera
  18462. */
  18463. clear(): void;
  18464. }
  18465. }
  18466. declare module BABYLON {
  18467. /**
  18468. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18469. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18471. */
  18472. export class FreeCamera extends TargetCamera {
  18473. /**
  18474. * Define the collision ellipsoid of the camera.
  18475. * This is helpful to simulate a camera body like the player body around the camera
  18476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18477. */
  18478. ellipsoid: Vector3;
  18479. /**
  18480. * Define an offset for the position of the ellipsoid around the camera.
  18481. * This can be helpful to determine the center of the body near the gravity center of the body
  18482. * instead of its head.
  18483. */
  18484. ellipsoidOffset: Vector3;
  18485. /**
  18486. * Enable or disable collisions of the camera with the rest of the scene objects.
  18487. */
  18488. checkCollisions: boolean;
  18489. /**
  18490. * Enable or disable gravity on the camera.
  18491. */
  18492. applyGravity: boolean;
  18493. /**
  18494. * Define the input manager associated to the camera.
  18495. */
  18496. inputs: FreeCameraInputsManager;
  18497. /**
  18498. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18499. * Higher values reduce sensitivity.
  18500. */
  18501. get angularSensibility(): number;
  18502. /**
  18503. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18504. * Higher values reduce sensitivity.
  18505. */
  18506. set angularSensibility(value: number);
  18507. /**
  18508. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18509. */
  18510. get keysUp(): number[];
  18511. set keysUp(value: number[]);
  18512. /**
  18513. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18514. */
  18515. get keysUpward(): number[];
  18516. set keysUpward(value: number[]);
  18517. /**
  18518. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18519. */
  18520. get keysDown(): number[];
  18521. set keysDown(value: number[]);
  18522. /**
  18523. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18524. */
  18525. get keysDownward(): number[];
  18526. set keysDownward(value: number[]);
  18527. /**
  18528. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18529. */
  18530. get keysLeft(): number[];
  18531. set keysLeft(value: number[]);
  18532. /**
  18533. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18534. */
  18535. get keysRight(): number[];
  18536. set keysRight(value: number[]);
  18537. /**
  18538. * Event raised when the camera collide with a mesh in the scene.
  18539. */
  18540. onCollide: (collidedMesh: AbstractMesh) => void;
  18541. private _collider;
  18542. private _needMoveForGravity;
  18543. private _oldPosition;
  18544. private _diffPosition;
  18545. private _newPosition;
  18546. /** @hidden */
  18547. _localDirection: Vector3;
  18548. /** @hidden */
  18549. _transformedDirection: Vector3;
  18550. /**
  18551. * Instantiates a Free Camera.
  18552. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18553. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18555. * @param name Define the name of the camera in the scene
  18556. * @param position Define the start position of the camera in the scene
  18557. * @param scene Define the scene the camera belongs to
  18558. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18559. */
  18560. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18561. /**
  18562. * Attached controls to the current camera.
  18563. * @param element Defines the element the controls should be listened from
  18564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18565. */
  18566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18567. /**
  18568. * Detach the current controls from the camera.
  18569. * The camera will stop reacting to inputs.
  18570. * @param element Defines the element to stop listening the inputs from
  18571. */
  18572. detachControl(element: HTMLElement): void;
  18573. private _collisionMask;
  18574. /**
  18575. * Define a collision mask to limit the list of object the camera can collide with
  18576. */
  18577. get collisionMask(): number;
  18578. set collisionMask(mask: number);
  18579. /** @hidden */
  18580. _collideWithWorld(displacement: Vector3): void;
  18581. private _onCollisionPositionChange;
  18582. /** @hidden */
  18583. _checkInputs(): void;
  18584. /** @hidden */
  18585. _decideIfNeedsToMove(): boolean;
  18586. /** @hidden */
  18587. _updatePosition(): void;
  18588. /**
  18589. * Destroy the camera and release the current resources hold by it.
  18590. */
  18591. dispose(): void;
  18592. /**
  18593. * Gets the current object class name.
  18594. * @return the class name
  18595. */
  18596. getClassName(): string;
  18597. }
  18598. }
  18599. declare module BABYLON {
  18600. /**
  18601. * Represents a gamepad control stick position
  18602. */
  18603. export class StickValues {
  18604. /**
  18605. * The x component of the control stick
  18606. */
  18607. x: number;
  18608. /**
  18609. * The y component of the control stick
  18610. */
  18611. y: number;
  18612. /**
  18613. * Initializes the gamepad x and y control stick values
  18614. * @param x The x component of the gamepad control stick value
  18615. * @param y The y component of the gamepad control stick value
  18616. */
  18617. constructor(
  18618. /**
  18619. * The x component of the control stick
  18620. */
  18621. x: number,
  18622. /**
  18623. * The y component of the control stick
  18624. */
  18625. y: number);
  18626. }
  18627. /**
  18628. * An interface which manages callbacks for gamepad button changes
  18629. */
  18630. export interface GamepadButtonChanges {
  18631. /**
  18632. * Called when a gamepad has been changed
  18633. */
  18634. changed: boolean;
  18635. /**
  18636. * Called when a gamepad press event has been triggered
  18637. */
  18638. pressChanged: boolean;
  18639. /**
  18640. * Called when a touch event has been triggered
  18641. */
  18642. touchChanged: boolean;
  18643. /**
  18644. * Called when a value has changed
  18645. */
  18646. valueChanged: boolean;
  18647. }
  18648. /**
  18649. * Represents a gamepad
  18650. */
  18651. export class Gamepad {
  18652. /**
  18653. * The id of the gamepad
  18654. */
  18655. id: string;
  18656. /**
  18657. * The index of the gamepad
  18658. */
  18659. index: number;
  18660. /**
  18661. * The browser gamepad
  18662. */
  18663. browserGamepad: any;
  18664. /**
  18665. * Specifies what type of gamepad this represents
  18666. */
  18667. type: number;
  18668. private _leftStick;
  18669. private _rightStick;
  18670. /** @hidden */
  18671. _isConnected: boolean;
  18672. private _leftStickAxisX;
  18673. private _leftStickAxisY;
  18674. private _rightStickAxisX;
  18675. private _rightStickAxisY;
  18676. /**
  18677. * Triggered when the left control stick has been changed
  18678. */
  18679. private _onleftstickchanged;
  18680. /**
  18681. * Triggered when the right control stick has been changed
  18682. */
  18683. private _onrightstickchanged;
  18684. /**
  18685. * Represents a gamepad controller
  18686. */
  18687. static GAMEPAD: number;
  18688. /**
  18689. * Represents a generic controller
  18690. */
  18691. static GENERIC: number;
  18692. /**
  18693. * Represents an XBox controller
  18694. */
  18695. static XBOX: number;
  18696. /**
  18697. * Represents a pose-enabled controller
  18698. */
  18699. static POSE_ENABLED: number;
  18700. /**
  18701. * Represents an Dual Shock controller
  18702. */
  18703. static DUALSHOCK: number;
  18704. /**
  18705. * Specifies whether the left control stick should be Y-inverted
  18706. */
  18707. protected _invertLeftStickY: boolean;
  18708. /**
  18709. * Specifies if the gamepad has been connected
  18710. */
  18711. get isConnected(): boolean;
  18712. /**
  18713. * Initializes the gamepad
  18714. * @param id The id of the gamepad
  18715. * @param index The index of the gamepad
  18716. * @param browserGamepad The browser gamepad
  18717. * @param leftStickX The x component of the left joystick
  18718. * @param leftStickY The y component of the left joystick
  18719. * @param rightStickX The x component of the right joystick
  18720. * @param rightStickY The y component of the right joystick
  18721. */
  18722. constructor(
  18723. /**
  18724. * The id of the gamepad
  18725. */
  18726. id: string,
  18727. /**
  18728. * The index of the gamepad
  18729. */
  18730. index: number,
  18731. /**
  18732. * The browser gamepad
  18733. */
  18734. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18735. /**
  18736. * Callback triggered when the left joystick has changed
  18737. * @param callback
  18738. */
  18739. onleftstickchanged(callback: (values: StickValues) => void): void;
  18740. /**
  18741. * Callback triggered when the right joystick has changed
  18742. * @param callback
  18743. */
  18744. onrightstickchanged(callback: (values: StickValues) => void): void;
  18745. /**
  18746. * Gets the left joystick
  18747. */
  18748. get leftStick(): StickValues;
  18749. /**
  18750. * Sets the left joystick values
  18751. */
  18752. set leftStick(newValues: StickValues);
  18753. /**
  18754. * Gets the right joystick
  18755. */
  18756. get rightStick(): StickValues;
  18757. /**
  18758. * Sets the right joystick value
  18759. */
  18760. set rightStick(newValues: StickValues);
  18761. /**
  18762. * Updates the gamepad joystick positions
  18763. */
  18764. update(): void;
  18765. /**
  18766. * Disposes the gamepad
  18767. */
  18768. dispose(): void;
  18769. }
  18770. /**
  18771. * Represents a generic gamepad
  18772. */
  18773. export class GenericPad extends Gamepad {
  18774. private _buttons;
  18775. private _onbuttondown;
  18776. private _onbuttonup;
  18777. /**
  18778. * Observable triggered when a button has been pressed
  18779. */
  18780. onButtonDownObservable: Observable<number>;
  18781. /**
  18782. * Observable triggered when a button has been released
  18783. */
  18784. onButtonUpObservable: Observable<number>;
  18785. /**
  18786. * Callback triggered when a button has been pressed
  18787. * @param callback Called when a button has been pressed
  18788. */
  18789. onbuttondown(callback: (buttonPressed: number) => void): void;
  18790. /**
  18791. * Callback triggered when a button has been released
  18792. * @param callback Called when a button has been released
  18793. */
  18794. onbuttonup(callback: (buttonReleased: number) => void): void;
  18795. /**
  18796. * Initializes the generic gamepad
  18797. * @param id The id of the generic gamepad
  18798. * @param index The index of the generic gamepad
  18799. * @param browserGamepad The browser gamepad
  18800. */
  18801. constructor(id: string, index: number, browserGamepad: any);
  18802. private _setButtonValue;
  18803. /**
  18804. * Updates the generic gamepad
  18805. */
  18806. update(): void;
  18807. /**
  18808. * Disposes the generic gamepad
  18809. */
  18810. dispose(): void;
  18811. }
  18812. }
  18813. declare module BABYLON {
  18814. /**
  18815. * Defines the types of pose enabled controllers that are supported
  18816. */
  18817. export enum PoseEnabledControllerType {
  18818. /**
  18819. * HTC Vive
  18820. */
  18821. VIVE = 0,
  18822. /**
  18823. * Oculus Rift
  18824. */
  18825. OCULUS = 1,
  18826. /**
  18827. * Windows mixed reality
  18828. */
  18829. WINDOWS = 2,
  18830. /**
  18831. * Samsung gear VR
  18832. */
  18833. GEAR_VR = 3,
  18834. /**
  18835. * Google Daydream
  18836. */
  18837. DAYDREAM = 4,
  18838. /**
  18839. * Generic
  18840. */
  18841. GENERIC = 5
  18842. }
  18843. /**
  18844. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18845. */
  18846. export interface MutableGamepadButton {
  18847. /**
  18848. * Value of the button/trigger
  18849. */
  18850. value: number;
  18851. /**
  18852. * If the button/trigger is currently touched
  18853. */
  18854. touched: boolean;
  18855. /**
  18856. * If the button/trigger is currently pressed
  18857. */
  18858. pressed: boolean;
  18859. }
  18860. /**
  18861. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18862. * @hidden
  18863. */
  18864. export interface ExtendedGamepadButton extends GamepadButton {
  18865. /**
  18866. * If the button/trigger is currently pressed
  18867. */
  18868. readonly pressed: boolean;
  18869. /**
  18870. * If the button/trigger is currently touched
  18871. */
  18872. readonly touched: boolean;
  18873. /**
  18874. * Value of the button/trigger
  18875. */
  18876. readonly value: number;
  18877. }
  18878. /** @hidden */
  18879. export interface _GamePadFactory {
  18880. /**
  18881. * Returns whether or not the current gamepad can be created for this type of controller.
  18882. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18883. * @returns true if it can be created, otherwise false
  18884. */
  18885. canCreate(gamepadInfo: any): boolean;
  18886. /**
  18887. * Creates a new instance of the Gamepad.
  18888. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18889. * @returns the new gamepad instance
  18890. */
  18891. create(gamepadInfo: any): Gamepad;
  18892. }
  18893. /**
  18894. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18895. */
  18896. export class PoseEnabledControllerHelper {
  18897. /** @hidden */
  18898. static _ControllerFactories: _GamePadFactory[];
  18899. /** @hidden */
  18900. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18901. /**
  18902. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18903. * @param vrGamepad the gamepad to initialized
  18904. * @returns a vr controller of the type the gamepad identified as
  18905. */
  18906. static InitiateController(vrGamepad: any): Gamepad;
  18907. }
  18908. /**
  18909. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18910. */
  18911. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18912. /**
  18913. * If the controller is used in a webXR session
  18914. */
  18915. isXR: boolean;
  18916. private _deviceRoomPosition;
  18917. private _deviceRoomRotationQuaternion;
  18918. /**
  18919. * The device position in babylon space
  18920. */
  18921. devicePosition: Vector3;
  18922. /**
  18923. * The device rotation in babylon space
  18924. */
  18925. deviceRotationQuaternion: Quaternion;
  18926. /**
  18927. * The scale factor of the device in babylon space
  18928. */
  18929. deviceScaleFactor: number;
  18930. /**
  18931. * (Likely devicePosition should be used instead) The device position in its room space
  18932. */
  18933. position: Vector3;
  18934. /**
  18935. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18936. */
  18937. rotationQuaternion: Quaternion;
  18938. /**
  18939. * The type of controller (Eg. Windows mixed reality)
  18940. */
  18941. controllerType: PoseEnabledControllerType;
  18942. protected _calculatedPosition: Vector3;
  18943. private _calculatedRotation;
  18944. /**
  18945. * The raw pose from the device
  18946. */
  18947. rawPose: DevicePose;
  18948. private _trackPosition;
  18949. private _maxRotationDistFromHeadset;
  18950. private _draggedRoomRotation;
  18951. /**
  18952. * @hidden
  18953. */
  18954. _disableTrackPosition(fixedPosition: Vector3): void;
  18955. /**
  18956. * Internal, the mesh attached to the controller
  18957. * @hidden
  18958. */
  18959. _mesh: Nullable<AbstractMesh>;
  18960. private _poseControlledCamera;
  18961. private _leftHandSystemQuaternion;
  18962. /**
  18963. * Internal, matrix used to convert room space to babylon space
  18964. * @hidden
  18965. */
  18966. _deviceToWorld: Matrix;
  18967. /**
  18968. * Node to be used when casting a ray from the controller
  18969. * @hidden
  18970. */
  18971. _pointingPoseNode: Nullable<TransformNode>;
  18972. /**
  18973. * Name of the child mesh that can be used to cast a ray from the controller
  18974. */
  18975. static readonly POINTING_POSE: string;
  18976. /**
  18977. * Creates a new PoseEnabledController from a gamepad
  18978. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18979. */
  18980. constructor(browserGamepad: any);
  18981. private _workingMatrix;
  18982. /**
  18983. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18984. */
  18985. update(): void;
  18986. /**
  18987. * Updates only the pose device and mesh without doing any button event checking
  18988. */
  18989. protected _updatePoseAndMesh(): void;
  18990. /**
  18991. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18992. * @param poseData raw pose fromthe device
  18993. */
  18994. updateFromDevice(poseData: DevicePose): void;
  18995. /**
  18996. * @hidden
  18997. */
  18998. _meshAttachedObservable: Observable<AbstractMesh>;
  18999. /**
  19000. * Attaches a mesh to the controller
  19001. * @param mesh the mesh to be attached
  19002. */
  19003. attachToMesh(mesh: AbstractMesh): void;
  19004. /**
  19005. * Attaches the controllers mesh to a camera
  19006. * @param camera the camera the mesh should be attached to
  19007. */
  19008. attachToPoseControlledCamera(camera: TargetCamera): void;
  19009. /**
  19010. * Disposes of the controller
  19011. */
  19012. dispose(): void;
  19013. /**
  19014. * The mesh that is attached to the controller
  19015. */
  19016. get mesh(): Nullable<AbstractMesh>;
  19017. /**
  19018. * Gets the ray of the controller in the direction the controller is pointing
  19019. * @param length the length the resulting ray should be
  19020. * @returns a ray in the direction the controller is pointing
  19021. */
  19022. getForwardRay(length?: number): Ray;
  19023. }
  19024. }
  19025. declare module BABYLON {
  19026. /**
  19027. * Defines the WebVRController object that represents controllers tracked in 3D space
  19028. */
  19029. export abstract class WebVRController extends PoseEnabledController {
  19030. /**
  19031. * Internal, the default controller model for the controller
  19032. */
  19033. protected _defaultModel: Nullable<AbstractMesh>;
  19034. /**
  19035. * Fired when the trigger state has changed
  19036. */
  19037. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19038. /**
  19039. * Fired when the main button state has changed
  19040. */
  19041. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19042. /**
  19043. * Fired when the secondary button state has changed
  19044. */
  19045. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19046. /**
  19047. * Fired when the pad state has changed
  19048. */
  19049. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19050. /**
  19051. * Fired when controllers stick values have changed
  19052. */
  19053. onPadValuesChangedObservable: Observable<StickValues>;
  19054. /**
  19055. * Array of button availible on the controller
  19056. */
  19057. protected _buttons: Array<MutableGamepadButton>;
  19058. private _onButtonStateChange;
  19059. /**
  19060. * Fired when a controller button's state has changed
  19061. * @param callback the callback containing the button that was modified
  19062. */
  19063. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19064. /**
  19065. * X and Y axis corresponding to the controllers joystick
  19066. */
  19067. pad: StickValues;
  19068. /**
  19069. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19070. */
  19071. hand: string;
  19072. /**
  19073. * The default controller model for the controller
  19074. */
  19075. get defaultModel(): Nullable<AbstractMesh>;
  19076. /**
  19077. * Creates a new WebVRController from a gamepad
  19078. * @param vrGamepad the gamepad that the WebVRController should be created from
  19079. */
  19080. constructor(vrGamepad: any);
  19081. /**
  19082. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19083. */
  19084. update(): void;
  19085. /**
  19086. * Function to be called when a button is modified
  19087. */
  19088. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19089. /**
  19090. * Loads a mesh and attaches it to the controller
  19091. * @param scene the scene the mesh should be added to
  19092. * @param meshLoaded callback for when the mesh has been loaded
  19093. */
  19094. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19095. private _setButtonValue;
  19096. private _changes;
  19097. private _checkChanges;
  19098. /**
  19099. * Disposes of th webVRCOntroller
  19100. */
  19101. dispose(): void;
  19102. }
  19103. }
  19104. declare module BABYLON {
  19105. /**
  19106. * The HemisphericLight simulates the ambient environment light,
  19107. * so the passed direction is the light reflection direction, not the incoming direction.
  19108. */
  19109. export class HemisphericLight extends Light {
  19110. /**
  19111. * The groundColor is the light in the opposite direction to the one specified during creation.
  19112. * 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.
  19113. */
  19114. groundColor: Color3;
  19115. /**
  19116. * The light reflection direction, not the incoming direction.
  19117. */
  19118. direction: Vector3;
  19119. /**
  19120. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19121. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19122. * The HemisphericLight can't cast shadows.
  19123. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19124. * @param name The friendly name of the light
  19125. * @param direction The direction of the light reflection
  19126. * @param scene The scene the light belongs to
  19127. */
  19128. constructor(name: string, direction: Vector3, scene: Scene);
  19129. protected _buildUniformLayout(): void;
  19130. /**
  19131. * Returns the string "HemisphericLight".
  19132. * @return The class name
  19133. */
  19134. getClassName(): string;
  19135. /**
  19136. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19137. * Returns the updated direction.
  19138. * @param target The target the direction should point to
  19139. * @return The computed direction
  19140. */
  19141. setDirectionToTarget(target: Vector3): Vector3;
  19142. /**
  19143. * Returns the shadow generator associated to the light.
  19144. * @returns Always null for hemispheric lights because it does not support shadows.
  19145. */
  19146. getShadowGenerator(): Nullable<IShadowGenerator>;
  19147. /**
  19148. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19149. * @param effect The effect to update
  19150. * @param lightIndex The index of the light in the effect to update
  19151. * @returns The hemispheric light
  19152. */
  19153. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19154. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19155. /**
  19156. * Computes the world matrix of the node
  19157. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19158. * @param useWasUpdatedFlag defines a reserved property
  19159. * @returns the world matrix
  19160. */
  19161. computeWorldMatrix(): Matrix;
  19162. /**
  19163. * Returns the integer 3.
  19164. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19165. */
  19166. getTypeID(): number;
  19167. /**
  19168. * Prepares the list of defines specific to the light type.
  19169. * @param defines the list of defines
  19170. * @param lightIndex defines the index of the light for the effect
  19171. */
  19172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19173. }
  19174. }
  19175. declare module BABYLON {
  19176. /** @hidden */
  19177. export var vrMultiviewToSingleviewPixelShader: {
  19178. name: string;
  19179. shader: string;
  19180. };
  19181. }
  19182. declare module BABYLON {
  19183. /**
  19184. * Renders to multiple views with a single draw call
  19185. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19186. */
  19187. export class MultiviewRenderTarget extends RenderTargetTexture {
  19188. /**
  19189. * Creates a multiview render target
  19190. * @param scene scene used with the render target
  19191. * @param size the size of the render target (used for each view)
  19192. */
  19193. constructor(scene: Scene, size?: number | {
  19194. width: number;
  19195. height: number;
  19196. } | {
  19197. ratio: number;
  19198. });
  19199. /**
  19200. * @hidden
  19201. * @param faceIndex the face index, if its a cube texture
  19202. */
  19203. _bindFrameBuffer(faceIndex?: number): void;
  19204. /**
  19205. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19206. * @returns the view count
  19207. */
  19208. getViewCount(): number;
  19209. }
  19210. }
  19211. declare module BABYLON {
  19212. /**
  19213. * Represents a camera frustum
  19214. */
  19215. export class Frustum {
  19216. /**
  19217. * Gets the planes representing the frustum
  19218. * @param transform matrix to be applied to the returned planes
  19219. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19220. */
  19221. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19222. /**
  19223. * Gets the near frustum plane transformed by the transform matrix
  19224. * @param transform transformation matrix to be applied to the resulting frustum plane
  19225. * @param frustumPlane the resuling frustum plane
  19226. */
  19227. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19228. /**
  19229. * Gets the far frustum plane transformed by the transform matrix
  19230. * @param transform transformation matrix to be applied to the resulting frustum plane
  19231. * @param frustumPlane the resuling frustum plane
  19232. */
  19233. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19234. /**
  19235. * Gets the left frustum plane transformed by the transform matrix
  19236. * @param transform transformation matrix to be applied to the resulting frustum plane
  19237. * @param frustumPlane the resuling frustum plane
  19238. */
  19239. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19240. /**
  19241. * Gets the right frustum plane transformed by the transform matrix
  19242. * @param transform transformation matrix to be applied to the resulting frustum plane
  19243. * @param frustumPlane the resuling frustum plane
  19244. */
  19245. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19246. /**
  19247. * Gets the top frustum plane transformed by the transform matrix
  19248. * @param transform transformation matrix to be applied to the resulting frustum plane
  19249. * @param frustumPlane the resuling frustum plane
  19250. */
  19251. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19252. /**
  19253. * Gets the bottom frustum plane transformed by the transform matrix
  19254. * @param transform transformation matrix to be applied to the resulting frustum plane
  19255. * @param frustumPlane the resuling frustum plane
  19256. */
  19257. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19258. /**
  19259. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19260. * @param transform transformation matrix to be applied to the resulting frustum planes
  19261. * @param frustumPlanes the resuling frustum planes
  19262. */
  19263. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19264. }
  19265. }
  19266. declare module BABYLON {
  19267. interface Engine {
  19268. /**
  19269. * Creates a new multiview render target
  19270. * @param width defines the width of the texture
  19271. * @param height defines the height of the texture
  19272. * @returns the created multiview texture
  19273. */
  19274. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19275. /**
  19276. * Binds a multiview framebuffer to be drawn to
  19277. * @param multiviewTexture texture to bind
  19278. */
  19279. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19280. }
  19281. interface Camera {
  19282. /**
  19283. * @hidden
  19284. * 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)
  19285. */
  19286. _useMultiviewToSingleView: boolean;
  19287. /**
  19288. * @hidden
  19289. * 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)
  19290. */
  19291. _multiviewTexture: Nullable<RenderTargetTexture>;
  19292. /**
  19293. * @hidden
  19294. * ensures the multiview texture of the camera exists and has the specified width/height
  19295. * @param width height to set on the multiview texture
  19296. * @param height width to set on the multiview texture
  19297. */
  19298. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19299. }
  19300. interface Scene {
  19301. /** @hidden */
  19302. _transformMatrixR: Matrix;
  19303. /** @hidden */
  19304. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19305. /** @hidden */
  19306. _createMultiviewUbo(): void;
  19307. /** @hidden */
  19308. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19309. /** @hidden */
  19310. _renderMultiviewToSingleView(camera: Camera): void;
  19311. }
  19312. }
  19313. declare module BABYLON {
  19314. /**
  19315. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19316. * This will not be used for webXR as it supports displaying texture arrays directly
  19317. */
  19318. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19319. /**
  19320. * Initializes a VRMultiviewToSingleview
  19321. * @param name name of the post process
  19322. * @param camera camera to be applied to
  19323. * @param scaleFactor scaling factor to the size of the output texture
  19324. */
  19325. constructor(name: string, camera: Camera, scaleFactor: number);
  19326. }
  19327. }
  19328. declare module BABYLON {
  19329. /**
  19330. * Interface used to define additional presentation attributes
  19331. */
  19332. export interface IVRPresentationAttributes {
  19333. /**
  19334. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19335. */
  19336. highRefreshRate: boolean;
  19337. /**
  19338. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19339. */
  19340. foveationLevel: number;
  19341. }
  19342. interface Engine {
  19343. /** @hidden */
  19344. _vrDisplay: any;
  19345. /** @hidden */
  19346. _vrSupported: boolean;
  19347. /** @hidden */
  19348. _oldSize: Size;
  19349. /** @hidden */
  19350. _oldHardwareScaleFactor: number;
  19351. /** @hidden */
  19352. _vrExclusivePointerMode: boolean;
  19353. /** @hidden */
  19354. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19355. /** @hidden */
  19356. _onVRDisplayPointerRestricted: () => void;
  19357. /** @hidden */
  19358. _onVRDisplayPointerUnrestricted: () => void;
  19359. /** @hidden */
  19360. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19361. /** @hidden */
  19362. _onVrDisplayDisconnect: Nullable<() => void>;
  19363. /** @hidden */
  19364. _onVrDisplayPresentChange: Nullable<() => void>;
  19365. /**
  19366. * Observable signaled when VR display mode changes
  19367. */
  19368. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19369. /**
  19370. * Observable signaled when VR request present is complete
  19371. */
  19372. onVRRequestPresentComplete: Observable<boolean>;
  19373. /**
  19374. * Observable signaled when VR request present starts
  19375. */
  19376. onVRRequestPresentStart: Observable<Engine>;
  19377. /**
  19378. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19379. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19380. */
  19381. isInVRExclusivePointerMode: boolean;
  19382. /**
  19383. * Gets a boolean indicating if a webVR device was detected
  19384. * @returns true if a webVR device was detected
  19385. */
  19386. isVRDevicePresent(): boolean;
  19387. /**
  19388. * Gets the current webVR device
  19389. * @returns the current webVR device (or null)
  19390. */
  19391. getVRDevice(): any;
  19392. /**
  19393. * Initializes a webVR display and starts listening to display change events
  19394. * The onVRDisplayChangedObservable will be notified upon these changes
  19395. * @returns A promise containing a VRDisplay and if vr is supported
  19396. */
  19397. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19398. /** @hidden */
  19399. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19400. /**
  19401. * Gets or sets the presentation attributes used to configure VR rendering
  19402. */
  19403. vrPresentationAttributes?: IVRPresentationAttributes;
  19404. /**
  19405. * Call this function to switch to webVR mode
  19406. * Will do nothing if webVR is not supported or if there is no webVR device
  19407. * @param options the webvr options provided to the camera. mainly used for multiview
  19408. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19409. */
  19410. enableVR(options: WebVROptions): void;
  19411. /** @hidden */
  19412. _onVRFullScreenTriggered(): void;
  19413. }
  19414. }
  19415. declare module BABYLON {
  19416. /**
  19417. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19418. * IMPORTANT!! The data is right-hand data.
  19419. * @export
  19420. * @interface DevicePose
  19421. */
  19422. export interface DevicePose {
  19423. /**
  19424. * The position of the device, values in array are [x,y,z].
  19425. */
  19426. readonly position: Nullable<Float32Array>;
  19427. /**
  19428. * The linearVelocity of the device, values in array are [x,y,z].
  19429. */
  19430. readonly linearVelocity: Nullable<Float32Array>;
  19431. /**
  19432. * The linearAcceleration of the device, values in array are [x,y,z].
  19433. */
  19434. readonly linearAcceleration: Nullable<Float32Array>;
  19435. /**
  19436. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19437. */
  19438. readonly orientation: Nullable<Float32Array>;
  19439. /**
  19440. * The angularVelocity of the device, values in array are [x,y,z].
  19441. */
  19442. readonly angularVelocity: Nullable<Float32Array>;
  19443. /**
  19444. * The angularAcceleration of the device, values in array are [x,y,z].
  19445. */
  19446. readonly angularAcceleration: Nullable<Float32Array>;
  19447. }
  19448. /**
  19449. * Interface representing a pose controlled object in Babylon.
  19450. * A pose controlled object has both regular pose values as well as pose values
  19451. * from an external device such as a VR head mounted display
  19452. */
  19453. export interface PoseControlled {
  19454. /**
  19455. * The position of the object in babylon space.
  19456. */
  19457. position: Vector3;
  19458. /**
  19459. * The rotation quaternion of the object in babylon space.
  19460. */
  19461. rotationQuaternion: Quaternion;
  19462. /**
  19463. * The position of the device in babylon space.
  19464. */
  19465. devicePosition?: Vector3;
  19466. /**
  19467. * The rotation quaternion of the device in babylon space.
  19468. */
  19469. deviceRotationQuaternion: Quaternion;
  19470. /**
  19471. * The raw pose coming from the device.
  19472. */
  19473. rawPose: Nullable<DevicePose>;
  19474. /**
  19475. * The scale of the device to be used when translating from device space to babylon space.
  19476. */
  19477. deviceScaleFactor: number;
  19478. /**
  19479. * Updates the poseControlled values based on the input device pose.
  19480. * @param poseData the pose data to update the object with
  19481. */
  19482. updateFromDevice(poseData: DevicePose): void;
  19483. }
  19484. /**
  19485. * Set of options to customize the webVRCamera
  19486. */
  19487. export interface WebVROptions {
  19488. /**
  19489. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19490. */
  19491. trackPosition?: boolean;
  19492. /**
  19493. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19494. */
  19495. positionScale?: number;
  19496. /**
  19497. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19498. */
  19499. displayName?: string;
  19500. /**
  19501. * Should the native controller meshes be initialized. (default: true)
  19502. */
  19503. controllerMeshes?: boolean;
  19504. /**
  19505. * Creating a default HemiLight only on controllers. (default: true)
  19506. */
  19507. defaultLightingOnControllers?: boolean;
  19508. /**
  19509. * If you don't want to use the default VR button of the helper. (default: false)
  19510. */
  19511. useCustomVRButton?: boolean;
  19512. /**
  19513. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19514. */
  19515. customVRButton?: HTMLButtonElement;
  19516. /**
  19517. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19518. */
  19519. rayLength?: number;
  19520. /**
  19521. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19522. */
  19523. defaultHeight?: number;
  19524. /**
  19525. * If multiview should be used if availible (default: false)
  19526. */
  19527. useMultiview?: boolean;
  19528. }
  19529. /**
  19530. * This represents a WebVR camera.
  19531. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19532. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19533. */
  19534. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19535. private webVROptions;
  19536. /**
  19537. * @hidden
  19538. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19539. */
  19540. _vrDevice: any;
  19541. /**
  19542. * The rawPose of the vrDevice.
  19543. */
  19544. rawPose: Nullable<DevicePose>;
  19545. private _onVREnabled;
  19546. private _specsVersion;
  19547. private _attached;
  19548. private _frameData;
  19549. protected _descendants: Array<Node>;
  19550. private _deviceRoomPosition;
  19551. /** @hidden */
  19552. _deviceRoomRotationQuaternion: Quaternion;
  19553. private _standingMatrix;
  19554. /**
  19555. * Represents device position in babylon space.
  19556. */
  19557. devicePosition: Vector3;
  19558. /**
  19559. * Represents device rotation in babylon space.
  19560. */
  19561. deviceRotationQuaternion: Quaternion;
  19562. /**
  19563. * The scale of the device to be used when translating from device space to babylon space.
  19564. */
  19565. deviceScaleFactor: number;
  19566. private _deviceToWorld;
  19567. private _worldToDevice;
  19568. /**
  19569. * References to the webVR controllers for the vrDevice.
  19570. */
  19571. controllers: Array<WebVRController>;
  19572. /**
  19573. * Emits an event when a controller is attached.
  19574. */
  19575. onControllersAttachedObservable: Observable<WebVRController[]>;
  19576. /**
  19577. * Emits an event when a controller's mesh has been loaded;
  19578. */
  19579. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19580. /**
  19581. * Emits an event when the HMD's pose has been updated.
  19582. */
  19583. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19584. private _poseSet;
  19585. /**
  19586. * If the rig cameras be used as parent instead of this camera.
  19587. */
  19588. rigParenting: boolean;
  19589. private _lightOnControllers;
  19590. private _defaultHeight?;
  19591. /**
  19592. * Instantiates a WebVRFreeCamera.
  19593. * @param name The name of the WebVRFreeCamera
  19594. * @param position The starting anchor position for the camera
  19595. * @param scene The scene the camera belongs to
  19596. * @param webVROptions a set of customizable options for the webVRCamera
  19597. */
  19598. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19599. /**
  19600. * Gets the device distance from the ground in meters.
  19601. * @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.
  19602. */
  19603. deviceDistanceToRoomGround(): number;
  19604. /**
  19605. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19606. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19607. */
  19608. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19609. /**
  19610. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19611. * @returns A promise with a boolean set to if the standing matrix is supported.
  19612. */
  19613. useStandingMatrixAsync(): Promise<boolean>;
  19614. /**
  19615. * Disposes the camera
  19616. */
  19617. dispose(): void;
  19618. /**
  19619. * Gets a vrController by name.
  19620. * @param name The name of the controller to retreive
  19621. * @returns the controller matching the name specified or null if not found
  19622. */
  19623. getControllerByName(name: string): Nullable<WebVRController>;
  19624. private _leftController;
  19625. /**
  19626. * The controller corresponding to the users left hand.
  19627. */
  19628. get leftController(): Nullable<WebVRController>;
  19629. private _rightController;
  19630. /**
  19631. * The controller corresponding to the users right hand.
  19632. */
  19633. get rightController(): Nullable<WebVRController>;
  19634. /**
  19635. * Casts a ray forward from the vrCamera's gaze.
  19636. * @param length Length of the ray (default: 100)
  19637. * @returns the ray corresponding to the gaze
  19638. */
  19639. getForwardRay(length?: number): Ray;
  19640. /**
  19641. * @hidden
  19642. * Updates the camera based on device's frame data
  19643. */
  19644. _checkInputs(): void;
  19645. /**
  19646. * Updates the poseControlled values based on the input device pose.
  19647. * @param poseData Pose coming from the device
  19648. */
  19649. updateFromDevice(poseData: DevicePose): void;
  19650. private _htmlElementAttached;
  19651. private _detachIfAttached;
  19652. /**
  19653. * WebVR's attach control will start broadcasting frames to the device.
  19654. * Note that in certain browsers (chrome for example) this function must be called
  19655. * within a user-interaction callback. Example:
  19656. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19657. *
  19658. * @param element html element to attach the vrDevice to
  19659. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19660. */
  19661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19662. /**
  19663. * Detaches the camera from the html element and disables VR
  19664. *
  19665. * @param element html element to detach from
  19666. */
  19667. detachControl(element: HTMLElement): void;
  19668. /**
  19669. * @returns the name of this class
  19670. */
  19671. getClassName(): string;
  19672. /**
  19673. * Calls resetPose on the vrDisplay
  19674. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19675. */
  19676. resetToCurrentRotation(): void;
  19677. /**
  19678. * @hidden
  19679. * Updates the rig cameras (left and right eye)
  19680. */
  19681. _updateRigCameras(): void;
  19682. private _workingVector;
  19683. private _oneVector;
  19684. private _workingMatrix;
  19685. private updateCacheCalled;
  19686. private _correctPositionIfNotTrackPosition;
  19687. /**
  19688. * @hidden
  19689. * Updates the cached values of the camera
  19690. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19691. */
  19692. _updateCache(ignoreParentClass?: boolean): void;
  19693. /**
  19694. * @hidden
  19695. * Get current device position in babylon world
  19696. */
  19697. _computeDevicePosition(): void;
  19698. /**
  19699. * Updates the current device position and rotation in the babylon world
  19700. */
  19701. update(): void;
  19702. /**
  19703. * @hidden
  19704. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19705. * @returns an identity matrix
  19706. */
  19707. _getViewMatrix(): Matrix;
  19708. private _tmpMatrix;
  19709. /**
  19710. * This function is called by the two RIG cameras.
  19711. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19712. * @hidden
  19713. */
  19714. _getWebVRViewMatrix(): Matrix;
  19715. /** @hidden */
  19716. _getWebVRProjectionMatrix(): Matrix;
  19717. private _onGamepadConnectedObserver;
  19718. private _onGamepadDisconnectedObserver;
  19719. private _updateCacheWhenTrackingDisabledObserver;
  19720. /**
  19721. * Initializes the controllers and their meshes
  19722. */
  19723. initControllers(): void;
  19724. }
  19725. }
  19726. declare module BABYLON {
  19727. /**
  19728. * Size options for a post process
  19729. */
  19730. export type PostProcessOptions = {
  19731. width: number;
  19732. height: number;
  19733. };
  19734. /**
  19735. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19736. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19737. */
  19738. export class PostProcess {
  19739. /** Name of the PostProcess. */
  19740. name: string;
  19741. /**
  19742. * Gets or sets the unique id of the post process
  19743. */
  19744. uniqueId: number;
  19745. /**
  19746. * Width of the texture to apply the post process on
  19747. */
  19748. width: number;
  19749. /**
  19750. * Height of the texture to apply the post process on
  19751. */
  19752. height: number;
  19753. /**
  19754. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19755. * @hidden
  19756. */
  19757. _outputTexture: Nullable<InternalTexture>;
  19758. /**
  19759. * Sampling mode used by the shader
  19760. * See https://doc.babylonjs.com/classes/3.1/texture
  19761. */
  19762. renderTargetSamplingMode: number;
  19763. /**
  19764. * Clear color to use when screen clearing
  19765. */
  19766. clearColor: Color4;
  19767. /**
  19768. * If the buffer needs to be cleared before applying the post process. (default: true)
  19769. * Should be set to false if shader will overwrite all previous pixels.
  19770. */
  19771. autoClear: boolean;
  19772. /**
  19773. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19774. */
  19775. alphaMode: number;
  19776. /**
  19777. * Sets the setAlphaBlendConstants of the babylon engine
  19778. */
  19779. alphaConstants: Color4;
  19780. /**
  19781. * Animations to be used for the post processing
  19782. */
  19783. animations: Animation[];
  19784. /**
  19785. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19786. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19787. */
  19788. enablePixelPerfectMode: boolean;
  19789. /**
  19790. * Force the postprocess to be applied without taking in account viewport
  19791. */
  19792. forceFullscreenViewport: boolean;
  19793. /**
  19794. * List of inspectable custom properties (used by the Inspector)
  19795. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19796. */
  19797. inspectableCustomProperties: IInspectable[];
  19798. /**
  19799. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19800. *
  19801. * | Value | Type | Description |
  19802. * | ----- | ----------------------------------- | ----------- |
  19803. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19804. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19805. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19806. *
  19807. */
  19808. scaleMode: number;
  19809. /**
  19810. * Force textures to be a power of two (default: false)
  19811. */
  19812. alwaysForcePOT: boolean;
  19813. private _samples;
  19814. /**
  19815. * Number of sample textures (default: 1)
  19816. */
  19817. get samples(): number;
  19818. set samples(n: number);
  19819. /**
  19820. * Modify the scale of the post process to be the same as the viewport (default: false)
  19821. */
  19822. adaptScaleToCurrentViewport: boolean;
  19823. private _camera;
  19824. private _scene;
  19825. private _engine;
  19826. private _options;
  19827. private _reusable;
  19828. private _textureType;
  19829. private _textureFormat;
  19830. /**
  19831. * Smart array of input and output textures for the post process.
  19832. * @hidden
  19833. */
  19834. _textures: SmartArray<InternalTexture>;
  19835. /**
  19836. * The index in _textures that corresponds to the output texture.
  19837. * @hidden
  19838. */
  19839. _currentRenderTextureInd: number;
  19840. private _effect;
  19841. private _samplers;
  19842. private _fragmentUrl;
  19843. private _vertexUrl;
  19844. private _parameters;
  19845. private _scaleRatio;
  19846. protected _indexParameters: any;
  19847. private _shareOutputWithPostProcess;
  19848. private _texelSize;
  19849. private _forcedOutputTexture;
  19850. /**
  19851. * Returns the fragment url or shader name used in the post process.
  19852. * @returns the fragment url or name in the shader store.
  19853. */
  19854. getEffectName(): string;
  19855. /**
  19856. * An event triggered when the postprocess is activated.
  19857. */
  19858. onActivateObservable: Observable<Camera>;
  19859. private _onActivateObserver;
  19860. /**
  19861. * A function that is added to the onActivateObservable
  19862. */
  19863. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19864. /**
  19865. * An event triggered when the postprocess changes its size.
  19866. */
  19867. onSizeChangedObservable: Observable<PostProcess>;
  19868. private _onSizeChangedObserver;
  19869. /**
  19870. * A function that is added to the onSizeChangedObservable
  19871. */
  19872. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19873. /**
  19874. * An event triggered when the postprocess applies its effect.
  19875. */
  19876. onApplyObservable: Observable<Effect>;
  19877. private _onApplyObserver;
  19878. /**
  19879. * A function that is added to the onApplyObservable
  19880. */
  19881. set onApply(callback: (effect: Effect) => void);
  19882. /**
  19883. * An event triggered before rendering the postprocess
  19884. */
  19885. onBeforeRenderObservable: Observable<Effect>;
  19886. private _onBeforeRenderObserver;
  19887. /**
  19888. * A function that is added to the onBeforeRenderObservable
  19889. */
  19890. set onBeforeRender(callback: (effect: Effect) => void);
  19891. /**
  19892. * An event triggered after rendering the postprocess
  19893. */
  19894. onAfterRenderObservable: Observable<Effect>;
  19895. private _onAfterRenderObserver;
  19896. /**
  19897. * A function that is added to the onAfterRenderObservable
  19898. */
  19899. set onAfterRender(callback: (efect: Effect) => void);
  19900. /**
  19901. * 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
  19902. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19903. */
  19904. get inputTexture(): InternalTexture;
  19905. set inputTexture(value: InternalTexture);
  19906. /**
  19907. * Gets the camera which post process is applied to.
  19908. * @returns The camera the post process is applied to.
  19909. */
  19910. getCamera(): Camera;
  19911. /**
  19912. * Gets the texel size of the postprocess.
  19913. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19914. */
  19915. get texelSize(): Vector2;
  19916. /**
  19917. * Creates a new instance PostProcess
  19918. * @param name The name of the PostProcess.
  19919. * @param fragmentUrl The url of the fragment shader to be used.
  19920. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19921. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19922. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19923. * @param camera The camera to apply the render pass to.
  19924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19925. * @param engine The engine which the post process will be applied. (default: current engine)
  19926. * @param reusable If the post process can be reused on the same frame. (default: false)
  19927. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19928. * @param textureType Type of textures used when performing the post process. (default: 0)
  19929. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19930. * @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
  19931. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19932. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19933. */
  19934. constructor(
  19935. /** Name of the PostProcess. */
  19936. 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);
  19937. /**
  19938. * Gets a string idenfifying the name of the class
  19939. * @returns "PostProcess" string
  19940. */
  19941. getClassName(): string;
  19942. /**
  19943. * Gets the engine which this post process belongs to.
  19944. * @returns The engine the post process was enabled with.
  19945. */
  19946. getEngine(): Engine;
  19947. /**
  19948. * The effect that is created when initializing the post process.
  19949. * @returns The created effect corresponding the the postprocess.
  19950. */
  19951. getEffect(): Effect;
  19952. /**
  19953. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19954. * @param postProcess The post process to share the output with.
  19955. * @returns This post process.
  19956. */
  19957. shareOutputWith(postProcess: PostProcess): PostProcess;
  19958. /**
  19959. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19960. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19961. */
  19962. useOwnOutput(): void;
  19963. /**
  19964. * Updates the effect with the current post process compile time values and recompiles the shader.
  19965. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19966. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19967. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19968. * @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
  19969. * @param onCompiled Called when the shader has been compiled.
  19970. * @param onError Called if there is an error when compiling a shader.
  19971. */
  19972. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19973. /**
  19974. * The post process is reusable if it can be used multiple times within one frame.
  19975. * @returns If the post process is reusable
  19976. */
  19977. isReusable(): boolean;
  19978. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19979. markTextureDirty(): void;
  19980. /**
  19981. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19982. * 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.
  19983. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19984. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19985. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19986. * @returns The target texture that was bound to be written to.
  19987. */
  19988. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19989. /**
  19990. * If the post process is supported.
  19991. */
  19992. get isSupported(): boolean;
  19993. /**
  19994. * The aspect ratio of the output texture.
  19995. */
  19996. get aspectRatio(): number;
  19997. /**
  19998. * Get a value indicating if the post-process is ready to be used
  19999. * @returns true if the post-process is ready (shader is compiled)
  20000. */
  20001. isReady(): boolean;
  20002. /**
  20003. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20004. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20005. */
  20006. apply(): Nullable<Effect>;
  20007. private _disposeTextures;
  20008. /**
  20009. * Disposes the post process.
  20010. * @param camera The camera to dispose the post process on.
  20011. */
  20012. dispose(camera?: Camera): void;
  20013. }
  20014. }
  20015. declare module BABYLON {
  20016. /** @hidden */
  20017. export var kernelBlurVaryingDeclaration: {
  20018. name: string;
  20019. shader: string;
  20020. };
  20021. }
  20022. declare module BABYLON {
  20023. /** @hidden */
  20024. export var kernelBlurFragment: {
  20025. name: string;
  20026. shader: string;
  20027. };
  20028. }
  20029. declare module BABYLON {
  20030. /** @hidden */
  20031. export var kernelBlurFragment2: {
  20032. name: string;
  20033. shader: string;
  20034. };
  20035. }
  20036. declare module BABYLON {
  20037. /** @hidden */
  20038. export var kernelBlurPixelShader: {
  20039. name: string;
  20040. shader: string;
  20041. };
  20042. }
  20043. declare module BABYLON {
  20044. /** @hidden */
  20045. export var kernelBlurVertex: {
  20046. name: string;
  20047. shader: string;
  20048. };
  20049. }
  20050. declare module BABYLON {
  20051. /** @hidden */
  20052. export var kernelBlurVertexShader: {
  20053. name: string;
  20054. shader: string;
  20055. };
  20056. }
  20057. declare module BABYLON {
  20058. /**
  20059. * The Blur Post Process which blurs an image based on a kernel and direction.
  20060. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20061. */
  20062. export class BlurPostProcess extends PostProcess {
  20063. /** The direction in which to blur the image. */
  20064. direction: Vector2;
  20065. private blockCompilation;
  20066. protected _kernel: number;
  20067. protected _idealKernel: number;
  20068. protected _packedFloat: boolean;
  20069. private _staticDefines;
  20070. /**
  20071. * Sets the length in pixels of the blur sample region
  20072. */
  20073. set kernel(v: number);
  20074. /**
  20075. * Gets the length in pixels of the blur sample region
  20076. */
  20077. get kernel(): number;
  20078. /**
  20079. * Sets wether or not the blur needs to unpack/repack floats
  20080. */
  20081. set packedFloat(v: boolean);
  20082. /**
  20083. * Gets wether or not the blur is unpacking/repacking floats
  20084. */
  20085. get packedFloat(): boolean;
  20086. /**
  20087. * Creates a new instance BlurPostProcess
  20088. * @param name The name of the effect.
  20089. * @param direction The direction in which to blur the image.
  20090. * @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.
  20091. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20092. * @param camera The camera to apply the render pass to.
  20093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20094. * @param engine The engine which the post process will be applied. (default: current engine)
  20095. * @param reusable If the post process can be reused on the same frame. (default: false)
  20096. * @param textureType Type of textures used when performing the post process. (default: 0)
  20097. * @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)
  20098. */
  20099. constructor(name: string,
  20100. /** The direction in which to blur the image. */
  20101. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20102. /**
  20103. * Updates the effect with the current post process compile time values and recompiles the shader.
  20104. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20105. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20106. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20107. * @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
  20108. * @param onCompiled Called when the shader has been compiled.
  20109. * @param onError Called if there is an error when compiling a shader.
  20110. */
  20111. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20112. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20113. /**
  20114. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20115. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20116. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20117. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20118. * The gaps between physical kernels are compensated for in the weighting of the samples
  20119. * @param idealKernel Ideal blur kernel.
  20120. * @return Nearest best kernel.
  20121. */
  20122. protected _nearestBestKernel(idealKernel: number): number;
  20123. /**
  20124. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20125. * @param x The point on the Gaussian distribution to sample.
  20126. * @return the value of the Gaussian function at x.
  20127. */
  20128. protected _gaussianWeight(x: number): number;
  20129. /**
  20130. * Generates a string that can be used as a floating point number in GLSL.
  20131. * @param x Value to print.
  20132. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20133. * @return GLSL float string.
  20134. */
  20135. protected _glslFloat(x: number, decimalFigures?: number): string;
  20136. }
  20137. }
  20138. declare module BABYLON {
  20139. /**
  20140. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20141. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20142. * You can then easily use it as a reflectionTexture on a flat surface.
  20143. * In case the surface is not a plane, please consider relying on reflection probes.
  20144. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20145. */
  20146. export class MirrorTexture extends RenderTargetTexture {
  20147. private scene;
  20148. /**
  20149. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20150. * 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.
  20151. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20152. */
  20153. mirrorPlane: Plane;
  20154. /**
  20155. * Define the blur ratio used to blur the reflection if needed.
  20156. */
  20157. set blurRatio(value: number);
  20158. get blurRatio(): number;
  20159. /**
  20160. * Define the adaptive blur kernel used to blur the reflection if needed.
  20161. * This will autocompute the closest best match for the `blurKernel`
  20162. */
  20163. set adaptiveBlurKernel(value: number);
  20164. /**
  20165. * Define the blur kernel used to blur the reflection if needed.
  20166. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20167. */
  20168. set blurKernel(value: number);
  20169. /**
  20170. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20171. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20172. */
  20173. set blurKernelX(value: number);
  20174. get blurKernelX(): number;
  20175. /**
  20176. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20177. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20178. */
  20179. set blurKernelY(value: number);
  20180. get blurKernelY(): number;
  20181. private _autoComputeBlurKernel;
  20182. protected _onRatioRescale(): void;
  20183. private _updateGammaSpace;
  20184. private _imageProcessingConfigChangeObserver;
  20185. private _transformMatrix;
  20186. private _mirrorMatrix;
  20187. private _savedViewMatrix;
  20188. private _blurX;
  20189. private _blurY;
  20190. private _adaptiveBlurKernel;
  20191. private _blurKernelX;
  20192. private _blurKernelY;
  20193. private _blurRatio;
  20194. /**
  20195. * Instantiates a Mirror Texture.
  20196. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20197. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20198. * You can then easily use it as a reflectionTexture on a flat surface.
  20199. * In case the surface is not a plane, please consider relying on reflection probes.
  20200. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20201. * @param name
  20202. * @param size
  20203. * @param scene
  20204. * @param generateMipMaps
  20205. * @param type
  20206. * @param samplingMode
  20207. * @param generateDepthBuffer
  20208. */
  20209. constructor(name: string, size: number | {
  20210. width: number;
  20211. height: number;
  20212. } | {
  20213. ratio: number;
  20214. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20215. private _preparePostProcesses;
  20216. /**
  20217. * Clone the mirror texture.
  20218. * @returns the cloned texture
  20219. */
  20220. clone(): MirrorTexture;
  20221. /**
  20222. * Serialize the texture to a JSON representation you could use in Parse later on
  20223. * @returns the serialized JSON representation
  20224. */
  20225. serialize(): any;
  20226. /**
  20227. * Dispose the texture and release its associated resources.
  20228. */
  20229. dispose(): void;
  20230. }
  20231. }
  20232. declare module BABYLON {
  20233. /**
  20234. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20235. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20236. */
  20237. export class Texture extends BaseTexture {
  20238. /**
  20239. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20240. */
  20241. static SerializeBuffers: boolean;
  20242. /** @hidden */
  20243. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20244. /** @hidden */
  20245. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20246. /** @hidden */
  20247. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20248. /** nearest is mag = nearest and min = nearest and mip = linear */
  20249. static readonly NEAREST_SAMPLINGMODE: number;
  20250. /** nearest is mag = nearest and min = nearest and mip = linear */
  20251. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20252. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20253. static readonly BILINEAR_SAMPLINGMODE: number;
  20254. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20255. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20256. /** Trilinear is mag = linear and min = linear and mip = linear */
  20257. static readonly TRILINEAR_SAMPLINGMODE: number;
  20258. /** Trilinear is mag = linear and min = linear and mip = linear */
  20259. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20260. /** mag = nearest and min = nearest and mip = nearest */
  20261. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20262. /** mag = nearest and min = linear and mip = nearest */
  20263. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20264. /** mag = nearest and min = linear and mip = linear */
  20265. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20266. /** mag = nearest and min = linear and mip = none */
  20267. static readonly NEAREST_LINEAR: number;
  20268. /** mag = nearest and min = nearest and mip = none */
  20269. static readonly NEAREST_NEAREST: number;
  20270. /** mag = linear and min = nearest and mip = nearest */
  20271. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20272. /** mag = linear and min = nearest and mip = linear */
  20273. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20274. /** mag = linear and min = linear and mip = none */
  20275. static readonly LINEAR_LINEAR: number;
  20276. /** mag = linear and min = nearest and mip = none */
  20277. static readonly LINEAR_NEAREST: number;
  20278. /** Explicit coordinates mode */
  20279. static readonly EXPLICIT_MODE: number;
  20280. /** Spherical coordinates mode */
  20281. static readonly SPHERICAL_MODE: number;
  20282. /** Planar coordinates mode */
  20283. static readonly PLANAR_MODE: number;
  20284. /** Cubic coordinates mode */
  20285. static readonly CUBIC_MODE: number;
  20286. /** Projection coordinates mode */
  20287. static readonly PROJECTION_MODE: number;
  20288. /** Inverse Cubic coordinates mode */
  20289. static readonly SKYBOX_MODE: number;
  20290. /** Inverse Cubic coordinates mode */
  20291. static readonly INVCUBIC_MODE: number;
  20292. /** Equirectangular coordinates mode */
  20293. static readonly EQUIRECTANGULAR_MODE: number;
  20294. /** Equirectangular Fixed coordinates mode */
  20295. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20296. /** Equirectangular Fixed Mirrored coordinates mode */
  20297. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20298. /** Texture is not repeating outside of 0..1 UVs */
  20299. static readonly CLAMP_ADDRESSMODE: number;
  20300. /** Texture is repeating outside of 0..1 UVs */
  20301. static readonly WRAP_ADDRESSMODE: number;
  20302. /** Texture is repeating and mirrored */
  20303. static readonly MIRROR_ADDRESSMODE: number;
  20304. /**
  20305. * 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
  20306. */
  20307. static UseSerializedUrlIfAny: boolean;
  20308. /**
  20309. * Define the url of the texture.
  20310. */
  20311. url: Nullable<string>;
  20312. /**
  20313. * Define an offset on the texture to offset the u coordinates of the UVs
  20314. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20315. */
  20316. uOffset: number;
  20317. /**
  20318. * Define an offset on the texture to offset the v coordinates of the UVs
  20319. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20320. */
  20321. vOffset: number;
  20322. /**
  20323. * Define an offset on the texture to scale the u coordinates of the UVs
  20324. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20325. */
  20326. uScale: number;
  20327. /**
  20328. * Define an offset on the texture to scale the v coordinates of the UVs
  20329. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20330. */
  20331. vScale: number;
  20332. /**
  20333. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20334. * @see http://doc.babylonjs.com/how_to/more_materials
  20335. */
  20336. uAng: number;
  20337. /**
  20338. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20339. * @see http://doc.babylonjs.com/how_to/more_materials
  20340. */
  20341. vAng: number;
  20342. /**
  20343. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20344. * @see http://doc.babylonjs.com/how_to/more_materials
  20345. */
  20346. wAng: number;
  20347. /**
  20348. * Defines the center of rotation (U)
  20349. */
  20350. uRotationCenter: number;
  20351. /**
  20352. * Defines the center of rotation (V)
  20353. */
  20354. vRotationCenter: number;
  20355. /**
  20356. * Defines the center of rotation (W)
  20357. */
  20358. wRotationCenter: number;
  20359. /**
  20360. * Are mip maps generated for this texture or not.
  20361. */
  20362. get noMipmap(): boolean;
  20363. /**
  20364. * List of inspectable custom properties (used by the Inspector)
  20365. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20366. */
  20367. inspectableCustomProperties: Nullable<IInspectable[]>;
  20368. private _noMipmap;
  20369. /** @hidden */
  20370. _invertY: boolean;
  20371. private _rowGenerationMatrix;
  20372. private _cachedTextureMatrix;
  20373. private _projectionModeMatrix;
  20374. private _t0;
  20375. private _t1;
  20376. private _t2;
  20377. private _cachedUOffset;
  20378. private _cachedVOffset;
  20379. private _cachedUScale;
  20380. private _cachedVScale;
  20381. private _cachedUAng;
  20382. private _cachedVAng;
  20383. private _cachedWAng;
  20384. private _cachedProjectionMatrixId;
  20385. private _cachedCoordinatesMode;
  20386. /** @hidden */
  20387. protected _initialSamplingMode: number;
  20388. /** @hidden */
  20389. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20390. private _deleteBuffer;
  20391. protected _format: Nullable<number>;
  20392. private _delayedOnLoad;
  20393. private _delayedOnError;
  20394. private _mimeType?;
  20395. /**
  20396. * Observable triggered once the texture has been loaded.
  20397. */
  20398. onLoadObservable: Observable<Texture>;
  20399. protected _isBlocking: boolean;
  20400. /**
  20401. * Is the texture preventing material to render while loading.
  20402. * If false, a default texture will be used instead of the loading one during the preparation step.
  20403. */
  20404. set isBlocking(value: boolean);
  20405. get isBlocking(): boolean;
  20406. /**
  20407. * Get the current sampling mode associated with the texture.
  20408. */
  20409. get samplingMode(): number;
  20410. /**
  20411. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20412. */
  20413. get invertY(): boolean;
  20414. /**
  20415. * Instantiates a new texture.
  20416. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20417. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20418. * @param url defines the url of the picture to load as a texture
  20419. * @param scene defines the scene or engine the texture will belong to
  20420. * @param noMipmap defines if the texture will require mip maps or not
  20421. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20422. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20423. * @param onLoad defines a callback triggered when the texture has been loaded
  20424. * @param onError defines a callback triggered when an error occurred during the loading session
  20425. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20426. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20427. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20428. * @param mimeType defines an optional mime type information
  20429. */
  20430. 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);
  20431. /**
  20432. * Update the url (and optional buffer) of this texture if url was null during construction.
  20433. * @param url the url of the texture
  20434. * @param buffer the buffer of the texture (defaults to null)
  20435. * @param onLoad callback called when the texture is loaded (defaults to null)
  20436. */
  20437. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20438. /**
  20439. * Finish the loading sequence of a texture flagged as delayed load.
  20440. * @hidden
  20441. */
  20442. delayLoad(): void;
  20443. private _prepareRowForTextureGeneration;
  20444. /**
  20445. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20446. * @returns the transform matrix of the texture.
  20447. */
  20448. getTextureMatrix(uBase?: number): Matrix;
  20449. /**
  20450. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20451. * @returns The reflection texture transform
  20452. */
  20453. getReflectionTextureMatrix(): Matrix;
  20454. /**
  20455. * Clones the texture.
  20456. * @returns the cloned texture
  20457. */
  20458. clone(): Texture;
  20459. /**
  20460. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20461. * @returns The JSON representation of the texture
  20462. */
  20463. serialize(): any;
  20464. /**
  20465. * Get the current class name of the texture useful for serialization or dynamic coding.
  20466. * @returns "Texture"
  20467. */
  20468. getClassName(): string;
  20469. /**
  20470. * Dispose the texture and release its associated resources.
  20471. */
  20472. dispose(): void;
  20473. /**
  20474. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20475. * @param parsedTexture Define the JSON representation of the texture
  20476. * @param scene Define the scene the parsed texture should be instantiated in
  20477. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20478. * @returns The parsed texture if successful
  20479. */
  20480. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20481. /**
  20482. * Creates a texture from its base 64 representation.
  20483. * @param data Define the base64 payload without the data: prefix
  20484. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20485. * @param scene Define the scene the texture should belong to
  20486. * @param noMipmap Forces the texture to not create mip map information if true
  20487. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20488. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20489. * @param onLoad define a callback triggered when the texture has been loaded
  20490. * @param onError define a callback triggered when an error occurred during the loading session
  20491. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20492. * @returns the created texture
  20493. */
  20494. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20495. /**
  20496. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20497. * @param data Define the base64 payload without the data: prefix
  20498. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20499. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20500. * @param scene Define the scene the texture should belong to
  20501. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20502. * @param noMipmap Forces the texture to not create mip map information if true
  20503. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20504. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20505. * @param onLoad define a callback triggered when the texture has been loaded
  20506. * @param onError define a callback triggered when an error occurred during the loading session
  20507. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20508. * @returns the created texture
  20509. */
  20510. 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;
  20511. }
  20512. }
  20513. declare module BABYLON {
  20514. /**
  20515. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20516. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20517. */
  20518. export class PostProcessManager {
  20519. private _scene;
  20520. private _indexBuffer;
  20521. private _vertexBuffers;
  20522. /**
  20523. * Creates a new instance PostProcess
  20524. * @param scene The scene that the post process is associated with.
  20525. */
  20526. constructor(scene: Scene);
  20527. private _prepareBuffers;
  20528. private _buildIndexBuffer;
  20529. /**
  20530. * Rebuilds the vertex buffers of the manager.
  20531. * @hidden
  20532. */
  20533. _rebuild(): void;
  20534. /**
  20535. * Prepares a frame to be run through a post process.
  20536. * @param sourceTexture The input texture to the post procesess. (default: null)
  20537. * @param postProcesses An array of post processes to be run. (default: null)
  20538. * @returns True if the post processes were able to be run.
  20539. * @hidden
  20540. */
  20541. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20542. /**
  20543. * Manually render a set of post processes to a texture.
  20544. * @param postProcesses An array of post processes to be run.
  20545. * @param targetTexture The target texture to render to.
  20546. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20547. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20548. * @param lodLevel defines which lod of the texture to render to
  20549. */
  20550. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20551. /**
  20552. * Finalize the result of the output of the postprocesses.
  20553. * @param doNotPresent If true the result will not be displayed to the screen.
  20554. * @param targetTexture The target texture to render to.
  20555. * @param faceIndex The index of the face to bind the target texture to.
  20556. * @param postProcesses The array of post processes to render.
  20557. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20558. * @hidden
  20559. */
  20560. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20561. /**
  20562. * Disposes of the post process manager.
  20563. */
  20564. dispose(): void;
  20565. }
  20566. }
  20567. declare module BABYLON {
  20568. /**
  20569. * This Helps creating a texture that will be created from a camera in your scene.
  20570. * It is basically a dynamic texture that could be used to create special effects for instance.
  20571. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20572. */
  20573. export class RenderTargetTexture extends Texture {
  20574. isCube: boolean;
  20575. /**
  20576. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20577. */
  20578. static readonly REFRESHRATE_RENDER_ONCE: number;
  20579. /**
  20580. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20581. */
  20582. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20583. /**
  20584. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20585. * the central point of your effect and can save a lot of performances.
  20586. */
  20587. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20588. /**
  20589. * Use this predicate to dynamically define the list of mesh you want to render.
  20590. * If set, the renderList property will be overwritten.
  20591. */
  20592. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20593. private _renderList;
  20594. /**
  20595. * Use this list to define the list of mesh you want to render.
  20596. */
  20597. get renderList(): Nullable<Array<AbstractMesh>>;
  20598. set renderList(value: Nullable<Array<AbstractMesh>>);
  20599. /**
  20600. * Use this function to overload the renderList array at rendering time.
  20601. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20602. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20603. * the cube (if the RTT is a cube, else layerOrFace=0).
  20604. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20605. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20606. * hold dummy elements!
  20607. */
  20608. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20609. private _hookArray;
  20610. /**
  20611. * Define if particles should be rendered in your texture.
  20612. */
  20613. renderParticles: boolean;
  20614. /**
  20615. * Define if sprites should be rendered in your texture.
  20616. */
  20617. renderSprites: boolean;
  20618. /**
  20619. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20620. */
  20621. coordinatesMode: number;
  20622. /**
  20623. * Define the camera used to render the texture.
  20624. */
  20625. activeCamera: Nullable<Camera>;
  20626. /**
  20627. * Override the mesh isReady function with your own one.
  20628. */
  20629. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20630. /**
  20631. * Override the render function of the texture with your own one.
  20632. */
  20633. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20634. /**
  20635. * Define if camera post processes should be use while rendering the texture.
  20636. */
  20637. useCameraPostProcesses: boolean;
  20638. /**
  20639. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20640. */
  20641. ignoreCameraViewport: boolean;
  20642. private _postProcessManager;
  20643. private _postProcesses;
  20644. private _resizeObserver;
  20645. /**
  20646. * An event triggered when the texture is unbind.
  20647. */
  20648. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20649. /**
  20650. * An event triggered when the texture is unbind.
  20651. */
  20652. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20653. private _onAfterUnbindObserver;
  20654. /**
  20655. * Set a after unbind callback in the texture.
  20656. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20657. */
  20658. set onAfterUnbind(callback: () => void);
  20659. /**
  20660. * An event triggered before rendering the texture
  20661. */
  20662. onBeforeRenderObservable: Observable<number>;
  20663. private _onBeforeRenderObserver;
  20664. /**
  20665. * Set a before render callback in the texture.
  20666. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20667. */
  20668. set onBeforeRender(callback: (faceIndex: number) => void);
  20669. /**
  20670. * An event triggered after rendering the texture
  20671. */
  20672. onAfterRenderObservable: Observable<number>;
  20673. private _onAfterRenderObserver;
  20674. /**
  20675. * Set a after render callback in the texture.
  20676. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20677. */
  20678. set onAfterRender(callback: (faceIndex: number) => void);
  20679. /**
  20680. * An event triggered after the texture clear
  20681. */
  20682. onClearObservable: Observable<Engine>;
  20683. private _onClearObserver;
  20684. /**
  20685. * Set a clear callback in the texture.
  20686. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20687. */
  20688. set onClear(callback: (Engine: Engine) => void);
  20689. /**
  20690. * An event triggered when the texture is resized.
  20691. */
  20692. onResizeObservable: Observable<RenderTargetTexture>;
  20693. /**
  20694. * Define the clear color of the Render Target if it should be different from the scene.
  20695. */
  20696. clearColor: Color4;
  20697. protected _size: number | {
  20698. width: number;
  20699. height: number;
  20700. layers?: number;
  20701. };
  20702. protected _initialSizeParameter: number | {
  20703. width: number;
  20704. height: number;
  20705. } | {
  20706. ratio: number;
  20707. };
  20708. protected _sizeRatio: Nullable<number>;
  20709. /** @hidden */
  20710. _generateMipMaps: boolean;
  20711. protected _renderingManager: RenderingManager;
  20712. /** @hidden */
  20713. _waitingRenderList: string[];
  20714. protected _doNotChangeAspectRatio: boolean;
  20715. protected _currentRefreshId: number;
  20716. protected _refreshRate: number;
  20717. protected _textureMatrix: Matrix;
  20718. protected _samples: number;
  20719. protected _renderTargetOptions: RenderTargetCreationOptions;
  20720. /**
  20721. * Gets render target creation options that were used.
  20722. */
  20723. get renderTargetOptions(): RenderTargetCreationOptions;
  20724. protected _engine: Engine;
  20725. protected _onRatioRescale(): void;
  20726. /**
  20727. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20728. * It must define where the camera used to render the texture is set
  20729. */
  20730. boundingBoxPosition: Vector3;
  20731. private _boundingBoxSize;
  20732. /**
  20733. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20734. * When defined, the cubemap will switch to local mode
  20735. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20736. * @example https://www.babylonjs-playground.com/#RNASML
  20737. */
  20738. set boundingBoxSize(value: Vector3);
  20739. get boundingBoxSize(): Vector3;
  20740. /**
  20741. * In case the RTT has been created with a depth texture, get the associated
  20742. * depth texture.
  20743. * Otherwise, return null.
  20744. */
  20745. get depthStencilTexture(): Nullable<InternalTexture>;
  20746. /**
  20747. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20748. * or used a shadow, depth texture...
  20749. * @param name The friendly name of the texture
  20750. * @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)
  20751. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20752. * @param generateMipMaps True if mip maps need to be generated after render.
  20753. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20754. * @param type The type of the buffer in the RTT (int, half float, float...)
  20755. * @param isCube True if a cube texture needs to be created
  20756. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20757. * @param generateDepthBuffer True to generate a depth buffer
  20758. * @param generateStencilBuffer True to generate a stencil buffer
  20759. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20760. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20761. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20762. */
  20763. constructor(name: string, size: number | {
  20764. width: number;
  20765. height: number;
  20766. layers?: number;
  20767. } | {
  20768. ratio: number;
  20769. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20770. /**
  20771. * Creates a depth stencil texture.
  20772. * This is only available in WebGL 2 or with the depth texture extension available.
  20773. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20774. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20775. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20776. */
  20777. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20778. private _processSizeParameter;
  20779. /**
  20780. * Define the number of samples to use in case of MSAA.
  20781. * It defaults to one meaning no MSAA has been enabled.
  20782. */
  20783. get samples(): number;
  20784. set samples(value: number);
  20785. /**
  20786. * Resets the refresh counter of the texture and start bak from scratch.
  20787. * Could be useful to regenerate the texture if it is setup to render only once.
  20788. */
  20789. resetRefreshCounter(): void;
  20790. /**
  20791. * Define the refresh rate of the texture or the rendering frequency.
  20792. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20793. */
  20794. get refreshRate(): number;
  20795. set refreshRate(value: number);
  20796. /**
  20797. * Adds a post process to the render target rendering passes.
  20798. * @param postProcess define the post process to add
  20799. */
  20800. addPostProcess(postProcess: PostProcess): void;
  20801. /**
  20802. * Clear all the post processes attached to the render target
  20803. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20804. */
  20805. clearPostProcesses(dispose?: boolean): void;
  20806. /**
  20807. * Remove one of the post process from the list of attached post processes to the texture
  20808. * @param postProcess define the post process to remove from the list
  20809. */
  20810. removePostProcess(postProcess: PostProcess): void;
  20811. /** @hidden */
  20812. _shouldRender(): boolean;
  20813. /**
  20814. * Gets the actual render size of the texture.
  20815. * @returns the width of the render size
  20816. */
  20817. getRenderSize(): number;
  20818. /**
  20819. * Gets the actual render width of the texture.
  20820. * @returns the width of the render size
  20821. */
  20822. getRenderWidth(): number;
  20823. /**
  20824. * Gets the actual render height of the texture.
  20825. * @returns the height of the render size
  20826. */
  20827. getRenderHeight(): number;
  20828. /**
  20829. * Gets the actual number of layers of the texture.
  20830. * @returns the number of layers
  20831. */
  20832. getRenderLayers(): number;
  20833. /**
  20834. * Get if the texture can be rescaled or not.
  20835. */
  20836. get canRescale(): boolean;
  20837. /**
  20838. * Resize the texture using a ratio.
  20839. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20840. */
  20841. scale(ratio: number): void;
  20842. /**
  20843. * Get the texture reflection matrix used to rotate/transform the reflection.
  20844. * @returns the reflection matrix
  20845. */
  20846. getReflectionTextureMatrix(): Matrix;
  20847. /**
  20848. * Resize the texture to a new desired size.
  20849. * Be carrefull as it will recreate all the data in the new texture.
  20850. * @param size Define the new size. It can be:
  20851. * - a number for squared texture,
  20852. * - an object containing { width: number, height: number }
  20853. * - or an object containing a ratio { ratio: number }
  20854. */
  20855. resize(size: number | {
  20856. width: number;
  20857. height: number;
  20858. } | {
  20859. ratio: number;
  20860. }): void;
  20861. private _defaultRenderListPrepared;
  20862. /**
  20863. * Renders all the objects from the render list into the texture.
  20864. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20865. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20866. */
  20867. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20868. private _bestReflectionRenderTargetDimension;
  20869. private _prepareRenderingManager;
  20870. /**
  20871. * @hidden
  20872. * @param faceIndex face index to bind to if this is a cubetexture
  20873. * @param layer defines the index of the texture to bind in the array
  20874. */
  20875. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20876. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20877. private renderToTarget;
  20878. /**
  20879. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20880. * This allowed control for front to back rendering or reversly depending of the special needs.
  20881. *
  20882. * @param renderingGroupId The rendering group id corresponding to its index
  20883. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20884. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20885. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20886. */
  20887. 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;
  20888. /**
  20889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20890. *
  20891. * @param renderingGroupId The rendering group id corresponding to its index
  20892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20893. */
  20894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20895. /**
  20896. * Clones the texture.
  20897. * @returns the cloned texture
  20898. */
  20899. clone(): RenderTargetTexture;
  20900. /**
  20901. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20902. * @returns The JSON representation of the texture
  20903. */
  20904. serialize(): any;
  20905. /**
  20906. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20907. */
  20908. disposeFramebufferObjects(): void;
  20909. /**
  20910. * Dispose the texture and release its associated resources.
  20911. */
  20912. dispose(): void;
  20913. /** @hidden */
  20914. _rebuild(): void;
  20915. /**
  20916. * Clear the info related to rendering groups preventing retention point in material dispose.
  20917. */
  20918. freeRenderingGroups(): void;
  20919. /**
  20920. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20921. * @returns the view count
  20922. */
  20923. getViewCount(): number;
  20924. }
  20925. }
  20926. declare module BABYLON {
  20927. /**
  20928. * Options for compiling materials.
  20929. */
  20930. export interface IMaterialCompilationOptions {
  20931. /**
  20932. * Defines whether clip planes are enabled.
  20933. */
  20934. clipPlane: boolean;
  20935. /**
  20936. * Defines whether instances are enabled.
  20937. */
  20938. useInstances: boolean;
  20939. }
  20940. /**
  20941. * Base class for the main features of a material in Babylon.js
  20942. */
  20943. export class Material implements IAnimatable {
  20944. /**
  20945. * Returns the triangle fill mode
  20946. */
  20947. static readonly TriangleFillMode: number;
  20948. /**
  20949. * Returns the wireframe mode
  20950. */
  20951. static readonly WireFrameFillMode: number;
  20952. /**
  20953. * Returns the point fill mode
  20954. */
  20955. static readonly PointFillMode: number;
  20956. /**
  20957. * Returns the point list draw mode
  20958. */
  20959. static readonly PointListDrawMode: number;
  20960. /**
  20961. * Returns the line list draw mode
  20962. */
  20963. static readonly LineListDrawMode: number;
  20964. /**
  20965. * Returns the line loop draw mode
  20966. */
  20967. static readonly LineLoopDrawMode: number;
  20968. /**
  20969. * Returns the line strip draw mode
  20970. */
  20971. static readonly LineStripDrawMode: number;
  20972. /**
  20973. * Returns the triangle strip draw mode
  20974. */
  20975. static readonly TriangleStripDrawMode: number;
  20976. /**
  20977. * Returns the triangle fan draw mode
  20978. */
  20979. static readonly TriangleFanDrawMode: number;
  20980. /**
  20981. * Stores the clock-wise side orientation
  20982. */
  20983. static readonly ClockWiseSideOrientation: number;
  20984. /**
  20985. * Stores the counter clock-wise side orientation
  20986. */
  20987. static readonly CounterClockWiseSideOrientation: number;
  20988. /**
  20989. * The dirty texture flag value
  20990. */
  20991. static readonly TextureDirtyFlag: number;
  20992. /**
  20993. * The dirty light flag value
  20994. */
  20995. static readonly LightDirtyFlag: number;
  20996. /**
  20997. * The dirty fresnel flag value
  20998. */
  20999. static readonly FresnelDirtyFlag: number;
  21000. /**
  21001. * The dirty attribute flag value
  21002. */
  21003. static readonly AttributesDirtyFlag: number;
  21004. /**
  21005. * The dirty misc flag value
  21006. */
  21007. static readonly MiscDirtyFlag: number;
  21008. /**
  21009. * The all dirty flag value
  21010. */
  21011. static readonly AllDirtyFlag: number;
  21012. /**
  21013. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21014. */
  21015. static readonly MATERIAL_OPAQUE: number;
  21016. /**
  21017. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21018. */
  21019. static readonly MATERIAL_ALPHATEST: number;
  21020. /**
  21021. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21022. */
  21023. static readonly MATERIAL_ALPHABLEND: number;
  21024. /**
  21025. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21026. * They are also discarded below the alpha cutoff threshold to improve performances.
  21027. */
  21028. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21029. /**
  21030. * The ID of the material
  21031. */
  21032. id: string;
  21033. /**
  21034. * Gets or sets the unique id of the material
  21035. */
  21036. uniqueId: number;
  21037. /**
  21038. * The name of the material
  21039. */
  21040. name: string;
  21041. /**
  21042. * Gets or sets user defined metadata
  21043. */
  21044. metadata: any;
  21045. /**
  21046. * For internal use only. Please do not use.
  21047. */
  21048. reservedDataStore: any;
  21049. /**
  21050. * Specifies if the ready state should be checked on each call
  21051. */
  21052. checkReadyOnEveryCall: boolean;
  21053. /**
  21054. * Specifies if the ready state should be checked once
  21055. */
  21056. checkReadyOnlyOnce: boolean;
  21057. /**
  21058. * The state of the material
  21059. */
  21060. state: string;
  21061. /**
  21062. * The alpha value of the material
  21063. */
  21064. protected _alpha: number;
  21065. /**
  21066. * List of inspectable custom properties (used by the Inspector)
  21067. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21068. */
  21069. inspectableCustomProperties: IInspectable[];
  21070. /**
  21071. * Sets the alpha value of the material
  21072. */
  21073. set alpha(value: number);
  21074. /**
  21075. * Gets the alpha value of the material
  21076. */
  21077. get alpha(): number;
  21078. /**
  21079. * Specifies if back face culling is enabled
  21080. */
  21081. protected _backFaceCulling: boolean;
  21082. /**
  21083. * Sets the back-face culling state
  21084. */
  21085. set backFaceCulling(value: boolean);
  21086. /**
  21087. * Gets the back-face culling state
  21088. */
  21089. get backFaceCulling(): boolean;
  21090. /**
  21091. * Stores the value for side orientation
  21092. */
  21093. sideOrientation: number;
  21094. /**
  21095. * Callback triggered when the material is compiled
  21096. */
  21097. onCompiled: Nullable<(effect: Effect) => void>;
  21098. /**
  21099. * Callback triggered when an error occurs
  21100. */
  21101. onError: Nullable<(effect: Effect, errors: string) => void>;
  21102. /**
  21103. * Callback triggered to get the render target textures
  21104. */
  21105. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21106. /**
  21107. * Gets a boolean indicating that current material needs to register RTT
  21108. */
  21109. get hasRenderTargetTextures(): boolean;
  21110. /**
  21111. * Specifies if the material should be serialized
  21112. */
  21113. doNotSerialize: boolean;
  21114. /**
  21115. * @hidden
  21116. */
  21117. _storeEffectOnSubMeshes: boolean;
  21118. /**
  21119. * Stores the animations for the material
  21120. */
  21121. animations: Nullable<Array<Animation>>;
  21122. /**
  21123. * An event triggered when the material is disposed
  21124. */
  21125. onDisposeObservable: Observable<Material>;
  21126. /**
  21127. * An observer which watches for dispose events
  21128. */
  21129. private _onDisposeObserver;
  21130. private _onUnBindObservable;
  21131. /**
  21132. * Called during a dispose event
  21133. */
  21134. set onDispose(callback: () => void);
  21135. private _onBindObservable;
  21136. /**
  21137. * An event triggered when the material is bound
  21138. */
  21139. get onBindObservable(): Observable<AbstractMesh>;
  21140. /**
  21141. * An observer which watches for bind events
  21142. */
  21143. private _onBindObserver;
  21144. /**
  21145. * Called during a bind event
  21146. */
  21147. set onBind(callback: (Mesh: AbstractMesh) => void);
  21148. /**
  21149. * An event triggered when the material is unbound
  21150. */
  21151. get onUnBindObservable(): Observable<Material>;
  21152. /**
  21153. * Stores the value of the alpha mode
  21154. */
  21155. private _alphaMode;
  21156. /**
  21157. * Sets the value of the alpha mode.
  21158. *
  21159. * | Value | Type | Description |
  21160. * | --- | --- | --- |
  21161. * | 0 | ALPHA_DISABLE | |
  21162. * | 1 | ALPHA_ADD | |
  21163. * | 2 | ALPHA_COMBINE | |
  21164. * | 3 | ALPHA_SUBTRACT | |
  21165. * | 4 | ALPHA_MULTIPLY | |
  21166. * | 5 | ALPHA_MAXIMIZED | |
  21167. * | 6 | ALPHA_ONEONE | |
  21168. * | 7 | ALPHA_PREMULTIPLIED | |
  21169. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21170. * | 9 | ALPHA_INTERPOLATE | |
  21171. * | 10 | ALPHA_SCREENMODE | |
  21172. *
  21173. */
  21174. set alphaMode(value: number);
  21175. /**
  21176. * Gets the value of the alpha mode
  21177. */
  21178. get alphaMode(): number;
  21179. /**
  21180. * Stores the state of the need depth pre-pass value
  21181. */
  21182. private _needDepthPrePass;
  21183. /**
  21184. * Sets the need depth pre-pass value
  21185. */
  21186. set needDepthPrePass(value: boolean);
  21187. /**
  21188. * Gets the depth pre-pass value
  21189. */
  21190. get needDepthPrePass(): boolean;
  21191. /**
  21192. * Specifies if depth writing should be disabled
  21193. */
  21194. disableDepthWrite: boolean;
  21195. /**
  21196. * Specifies if depth writing should be forced
  21197. */
  21198. forceDepthWrite: boolean;
  21199. /**
  21200. * Specifies the depth function that should be used. 0 means the default engine function
  21201. */
  21202. depthFunction: number;
  21203. /**
  21204. * Specifies if there should be a separate pass for culling
  21205. */
  21206. separateCullingPass: boolean;
  21207. /**
  21208. * Stores the state specifing if fog should be enabled
  21209. */
  21210. private _fogEnabled;
  21211. /**
  21212. * Sets the state for enabling fog
  21213. */
  21214. set fogEnabled(value: boolean);
  21215. /**
  21216. * Gets the value of the fog enabled state
  21217. */
  21218. get fogEnabled(): boolean;
  21219. /**
  21220. * Stores the size of points
  21221. */
  21222. pointSize: number;
  21223. /**
  21224. * Stores the z offset value
  21225. */
  21226. zOffset: number;
  21227. /**
  21228. * Gets a value specifying if wireframe mode is enabled
  21229. */
  21230. get wireframe(): boolean;
  21231. /**
  21232. * Sets the state of wireframe mode
  21233. */
  21234. set wireframe(value: boolean);
  21235. /**
  21236. * Gets the value specifying if point clouds are enabled
  21237. */
  21238. get pointsCloud(): boolean;
  21239. /**
  21240. * Sets the state of point cloud mode
  21241. */
  21242. set pointsCloud(value: boolean);
  21243. /**
  21244. * Gets the material fill mode
  21245. */
  21246. get fillMode(): number;
  21247. /**
  21248. * Sets the material fill mode
  21249. */
  21250. set fillMode(value: number);
  21251. /**
  21252. * @hidden
  21253. * Stores the effects for the material
  21254. */
  21255. _effect: Nullable<Effect>;
  21256. /**
  21257. * Specifies if uniform buffers should be used
  21258. */
  21259. private _useUBO;
  21260. /**
  21261. * Stores a reference to the scene
  21262. */
  21263. private _scene;
  21264. /**
  21265. * Stores the fill mode state
  21266. */
  21267. private _fillMode;
  21268. /**
  21269. * Specifies if the depth write state should be cached
  21270. */
  21271. private _cachedDepthWriteState;
  21272. /**
  21273. * Specifies if the depth function state should be cached
  21274. */
  21275. private _cachedDepthFunctionState;
  21276. /**
  21277. * Stores the uniform buffer
  21278. */
  21279. protected _uniformBuffer: UniformBuffer;
  21280. /** @hidden */
  21281. _indexInSceneMaterialArray: number;
  21282. /** @hidden */
  21283. meshMap: Nullable<{
  21284. [id: string]: AbstractMesh | undefined;
  21285. }>;
  21286. /**
  21287. * Creates a material instance
  21288. * @param name defines the name of the material
  21289. * @param scene defines the scene to reference
  21290. * @param doNotAdd specifies if the material should be added to the scene
  21291. */
  21292. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21293. /**
  21294. * Returns a string representation of the current material
  21295. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21296. * @returns a string with material information
  21297. */
  21298. toString(fullDetails?: boolean): string;
  21299. /**
  21300. * Gets the class name of the material
  21301. * @returns a string with the class name of the material
  21302. */
  21303. getClassName(): string;
  21304. /**
  21305. * Specifies if updates for the material been locked
  21306. */
  21307. get isFrozen(): boolean;
  21308. /**
  21309. * Locks updates for the material
  21310. */
  21311. freeze(): void;
  21312. /**
  21313. * Unlocks updates for the material
  21314. */
  21315. unfreeze(): void;
  21316. /**
  21317. * Specifies if the material is ready to be used
  21318. * @param mesh defines the mesh to check
  21319. * @param useInstances specifies if instances should be used
  21320. * @returns a boolean indicating if the material is ready to be used
  21321. */
  21322. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21323. /**
  21324. * Specifies that the submesh is ready to be used
  21325. * @param mesh defines the mesh to check
  21326. * @param subMesh defines which submesh to check
  21327. * @param useInstances specifies that instances should be used
  21328. * @returns a boolean indicating that the submesh is ready or not
  21329. */
  21330. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21331. /**
  21332. * Returns the material effect
  21333. * @returns the effect associated with the material
  21334. */
  21335. getEffect(): Nullable<Effect>;
  21336. /**
  21337. * Returns the current scene
  21338. * @returns a Scene
  21339. */
  21340. getScene(): Scene;
  21341. /**
  21342. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21343. */
  21344. protected _forceAlphaTest: boolean;
  21345. /**
  21346. * The transparency mode of the material.
  21347. */
  21348. protected _transparencyMode: Nullable<number>;
  21349. /**
  21350. * Gets the current transparency mode.
  21351. */
  21352. get transparencyMode(): Nullable<number>;
  21353. /**
  21354. * Sets the transparency mode of the material.
  21355. *
  21356. * | Value | Type | Description |
  21357. * | ----- | ----------------------------------- | ----------- |
  21358. * | 0 | OPAQUE | |
  21359. * | 1 | ALPHATEST | |
  21360. * | 2 | ALPHABLEND | |
  21361. * | 3 | ALPHATESTANDBLEND | |
  21362. *
  21363. */
  21364. set transparencyMode(value: Nullable<number>);
  21365. /**
  21366. * Returns true if alpha blending should be disabled.
  21367. */
  21368. protected get _disableAlphaBlending(): boolean;
  21369. /**
  21370. * Specifies whether or not this material should be rendered in alpha blend mode.
  21371. * @returns a boolean specifying if alpha blending is needed
  21372. */
  21373. needAlphaBlending(): boolean;
  21374. /**
  21375. * Specifies if the mesh will require alpha blending
  21376. * @param mesh defines the mesh to check
  21377. * @returns a boolean specifying if alpha blending is needed for the mesh
  21378. */
  21379. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21380. /**
  21381. * Specifies whether or not this material should be rendered in alpha test mode.
  21382. * @returns a boolean specifying if an alpha test is needed.
  21383. */
  21384. needAlphaTesting(): boolean;
  21385. /**
  21386. * Specifies if material alpha testing should be turned on for the mesh
  21387. * @param mesh defines the mesh to check
  21388. */
  21389. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21390. /**
  21391. * Gets the texture used for the alpha test
  21392. * @returns the texture to use for alpha testing
  21393. */
  21394. getAlphaTestTexture(): Nullable<BaseTexture>;
  21395. /**
  21396. * Marks the material to indicate that it needs to be re-calculated
  21397. */
  21398. markDirty(): void;
  21399. /** @hidden */
  21400. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21401. /**
  21402. * Binds the material to the mesh
  21403. * @param world defines the world transformation matrix
  21404. * @param mesh defines the mesh to bind the material to
  21405. */
  21406. bind(world: Matrix, mesh?: Mesh): void;
  21407. /**
  21408. * Binds the submesh to the material
  21409. * @param world defines the world transformation matrix
  21410. * @param mesh defines the mesh containing the submesh
  21411. * @param subMesh defines the submesh to bind the material to
  21412. */
  21413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21414. /**
  21415. * Binds the world matrix to the material
  21416. * @param world defines the world transformation matrix
  21417. */
  21418. bindOnlyWorldMatrix(world: Matrix): void;
  21419. /**
  21420. * Binds the scene's uniform buffer to the effect.
  21421. * @param effect defines the effect to bind to the scene uniform buffer
  21422. * @param sceneUbo defines the uniform buffer storing scene data
  21423. */
  21424. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21425. /**
  21426. * Binds the view matrix to the effect
  21427. * @param effect defines the effect to bind the view matrix to
  21428. */
  21429. bindView(effect: Effect): void;
  21430. /**
  21431. * Binds the view projection matrix to the effect
  21432. * @param effect defines the effect to bind the view projection matrix to
  21433. */
  21434. bindViewProjection(effect: Effect): void;
  21435. /**
  21436. * Processes to execute after binding the material to a mesh
  21437. * @param mesh defines the rendered mesh
  21438. */
  21439. protected _afterBind(mesh?: Mesh): void;
  21440. /**
  21441. * Unbinds the material from the mesh
  21442. */
  21443. unbind(): void;
  21444. /**
  21445. * Gets the active textures from the material
  21446. * @returns an array of textures
  21447. */
  21448. getActiveTextures(): BaseTexture[];
  21449. /**
  21450. * Specifies if the material uses a texture
  21451. * @param texture defines the texture to check against the material
  21452. * @returns a boolean specifying if the material uses the texture
  21453. */
  21454. hasTexture(texture: BaseTexture): boolean;
  21455. /**
  21456. * Makes a duplicate of the material, and gives it a new name
  21457. * @param name defines the new name for the duplicated material
  21458. * @returns the cloned material
  21459. */
  21460. clone(name: string): Nullable<Material>;
  21461. /**
  21462. * Gets the meshes bound to the material
  21463. * @returns an array of meshes bound to the material
  21464. */
  21465. getBindedMeshes(): AbstractMesh[];
  21466. /**
  21467. * Force shader compilation
  21468. * @param mesh defines the mesh associated with this material
  21469. * @param onCompiled defines a function to execute once the material is compiled
  21470. * @param options defines the options to configure the compilation
  21471. * @param onError defines a function to execute if the material fails compiling
  21472. */
  21473. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21474. /**
  21475. * Force shader compilation
  21476. * @param mesh defines the mesh that will use this material
  21477. * @param options defines additional options for compiling the shaders
  21478. * @returns a promise that resolves when the compilation completes
  21479. */
  21480. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21481. private static readonly _AllDirtyCallBack;
  21482. private static readonly _ImageProcessingDirtyCallBack;
  21483. private static readonly _TextureDirtyCallBack;
  21484. private static readonly _FresnelDirtyCallBack;
  21485. private static readonly _MiscDirtyCallBack;
  21486. private static readonly _LightsDirtyCallBack;
  21487. private static readonly _AttributeDirtyCallBack;
  21488. private static _FresnelAndMiscDirtyCallBack;
  21489. private static _TextureAndMiscDirtyCallBack;
  21490. private static readonly _DirtyCallbackArray;
  21491. private static readonly _RunDirtyCallBacks;
  21492. /**
  21493. * Marks a define in the material to indicate that it needs to be re-computed
  21494. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21495. */
  21496. markAsDirty(flag: number): void;
  21497. /**
  21498. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21499. * @param func defines a function which checks material defines against the submeshes
  21500. */
  21501. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21502. /**
  21503. * Indicates that we need to re-calculated for all submeshes
  21504. */
  21505. protected _markAllSubMeshesAsAllDirty(): void;
  21506. /**
  21507. * Indicates that image processing needs to be re-calculated for all submeshes
  21508. */
  21509. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21510. /**
  21511. * Indicates that textures need to be re-calculated for all submeshes
  21512. */
  21513. protected _markAllSubMeshesAsTexturesDirty(): void;
  21514. /**
  21515. * Indicates that fresnel needs to be re-calculated for all submeshes
  21516. */
  21517. protected _markAllSubMeshesAsFresnelDirty(): void;
  21518. /**
  21519. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21520. */
  21521. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21522. /**
  21523. * Indicates that lights need to be re-calculated for all submeshes
  21524. */
  21525. protected _markAllSubMeshesAsLightsDirty(): void;
  21526. /**
  21527. * Indicates that attributes need to be re-calculated for all submeshes
  21528. */
  21529. protected _markAllSubMeshesAsAttributesDirty(): void;
  21530. /**
  21531. * Indicates that misc needs to be re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsMiscDirty(): void;
  21534. /**
  21535. * Indicates that textures and misc need to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21538. /**
  21539. * Disposes the material
  21540. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21541. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21542. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21543. */
  21544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21545. /** @hidden */
  21546. private releaseVertexArrayObject;
  21547. /**
  21548. * Serializes this material
  21549. * @returns the serialized material object
  21550. */
  21551. serialize(): any;
  21552. /**
  21553. * Creates a material from parsed material data
  21554. * @param parsedMaterial defines parsed material data
  21555. * @param scene defines the hosting scene
  21556. * @param rootUrl defines the root URL to use to load textures
  21557. * @returns a new material
  21558. */
  21559. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21560. }
  21561. }
  21562. declare module BABYLON {
  21563. /**
  21564. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21565. * separate meshes. This can be use to improve performances.
  21566. * @see http://doc.babylonjs.com/how_to/multi_materials
  21567. */
  21568. export class MultiMaterial extends Material {
  21569. private _subMaterials;
  21570. /**
  21571. * Gets or Sets the list of Materials used within the multi material.
  21572. * They need to be ordered according to the submeshes order in the associated mesh
  21573. */
  21574. get subMaterials(): Nullable<Material>[];
  21575. set subMaterials(value: Nullable<Material>[]);
  21576. /**
  21577. * Function used to align with Node.getChildren()
  21578. * @returns the list of Materials used within the multi material
  21579. */
  21580. getChildren(): Nullable<Material>[];
  21581. /**
  21582. * Instantiates a new Multi Material
  21583. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21584. * separate meshes. This can be use to improve performances.
  21585. * @see http://doc.babylonjs.com/how_to/multi_materials
  21586. * @param name Define the name in the scene
  21587. * @param scene Define the scene the material belongs to
  21588. */
  21589. constructor(name: string, scene: Scene);
  21590. private _hookArray;
  21591. /**
  21592. * Get one of the submaterial by its index in the submaterials array
  21593. * @param index The index to look the sub material at
  21594. * @returns The Material if the index has been defined
  21595. */
  21596. getSubMaterial(index: number): Nullable<Material>;
  21597. /**
  21598. * Get the list of active textures for the whole sub materials list.
  21599. * @returns All the textures that will be used during the rendering
  21600. */
  21601. getActiveTextures(): BaseTexture[];
  21602. /**
  21603. * Gets the current class name of the material e.g. "MultiMaterial"
  21604. * Mainly use in serialization.
  21605. * @returns the class name
  21606. */
  21607. getClassName(): string;
  21608. /**
  21609. * Checks if the material is ready to render the requested sub mesh
  21610. * @param mesh Define the mesh the submesh belongs to
  21611. * @param subMesh Define the sub mesh to look readyness for
  21612. * @param useInstances Define whether or not the material is used with instances
  21613. * @returns true if ready, otherwise false
  21614. */
  21615. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21616. /**
  21617. * Clones the current material and its related sub materials
  21618. * @param name Define the name of the newly cloned material
  21619. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21620. * @returns the cloned material
  21621. */
  21622. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21623. /**
  21624. * Serializes the materials into a JSON representation.
  21625. * @returns the JSON representation
  21626. */
  21627. serialize(): any;
  21628. /**
  21629. * Dispose the material and release its associated resources
  21630. * @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)
  21631. * @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)
  21632. * @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)
  21633. */
  21634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21635. /**
  21636. * Creates a MultiMaterial from parsed MultiMaterial data.
  21637. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21638. * @param scene defines the hosting scene
  21639. * @returns a new MultiMaterial
  21640. */
  21641. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21642. }
  21643. }
  21644. declare module BABYLON {
  21645. /**
  21646. * Base class for submeshes
  21647. */
  21648. export class BaseSubMesh {
  21649. /** @hidden */
  21650. _materialDefines: Nullable<MaterialDefines>;
  21651. /** @hidden */
  21652. _materialEffect: Nullable<Effect>;
  21653. /**
  21654. * Gets material defines used by the effect associated to the sub mesh
  21655. */
  21656. get materialDefines(): Nullable<MaterialDefines>;
  21657. /**
  21658. * Sets material defines used by the effect associated to the sub mesh
  21659. */
  21660. set materialDefines(defines: Nullable<MaterialDefines>);
  21661. /**
  21662. * Gets associated effect
  21663. */
  21664. get effect(): Nullable<Effect>;
  21665. /**
  21666. * Sets associated effect (effect used to render this submesh)
  21667. * @param effect defines the effect to associate with
  21668. * @param defines defines the set of defines used to compile this effect
  21669. */
  21670. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21671. }
  21672. /**
  21673. * Defines a subdivision inside a mesh
  21674. */
  21675. export class SubMesh extends BaseSubMesh implements ICullable {
  21676. /** the material index to use */
  21677. materialIndex: number;
  21678. /** vertex index start */
  21679. verticesStart: number;
  21680. /** vertices count */
  21681. verticesCount: number;
  21682. /** index start */
  21683. indexStart: number;
  21684. /** indices count */
  21685. indexCount: number;
  21686. /** @hidden */
  21687. _linesIndexCount: number;
  21688. private _mesh;
  21689. private _renderingMesh;
  21690. private _boundingInfo;
  21691. private _linesIndexBuffer;
  21692. /** @hidden */
  21693. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21694. /** @hidden */
  21695. _trianglePlanes: Plane[];
  21696. /** @hidden */
  21697. _lastColliderTransformMatrix: Nullable<Matrix>;
  21698. /** @hidden */
  21699. _renderId: number;
  21700. /** @hidden */
  21701. _alphaIndex: number;
  21702. /** @hidden */
  21703. _distanceToCamera: number;
  21704. /** @hidden */
  21705. _id: number;
  21706. private _currentMaterial;
  21707. /**
  21708. * Add a new submesh to a mesh
  21709. * @param materialIndex defines the material index to use
  21710. * @param verticesStart defines vertex index start
  21711. * @param verticesCount defines vertices count
  21712. * @param indexStart defines index start
  21713. * @param indexCount defines indices count
  21714. * @param mesh defines the parent mesh
  21715. * @param renderingMesh defines an optional rendering mesh
  21716. * @param createBoundingBox defines if bounding box should be created for this submesh
  21717. * @returns the new submesh
  21718. */
  21719. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21720. /**
  21721. * Creates a new submesh
  21722. * @param materialIndex defines the material index to use
  21723. * @param verticesStart defines vertex index start
  21724. * @param verticesCount defines vertices count
  21725. * @param indexStart defines index start
  21726. * @param indexCount defines indices count
  21727. * @param mesh defines the parent mesh
  21728. * @param renderingMesh defines an optional rendering mesh
  21729. * @param createBoundingBox defines if bounding box should be created for this submesh
  21730. */
  21731. constructor(
  21732. /** the material index to use */
  21733. materialIndex: number,
  21734. /** vertex index start */
  21735. verticesStart: number,
  21736. /** vertices count */
  21737. verticesCount: number,
  21738. /** index start */
  21739. indexStart: number,
  21740. /** indices count */
  21741. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21742. /**
  21743. * Returns true if this submesh covers the entire parent mesh
  21744. * @ignorenaming
  21745. */
  21746. get IsGlobal(): boolean;
  21747. /**
  21748. * Returns the submesh BoudingInfo object
  21749. * @returns current bounding info (or mesh's one if the submesh is global)
  21750. */
  21751. getBoundingInfo(): BoundingInfo;
  21752. /**
  21753. * Sets the submesh BoundingInfo
  21754. * @param boundingInfo defines the new bounding info to use
  21755. * @returns the SubMesh
  21756. */
  21757. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21758. /**
  21759. * Returns the mesh of the current submesh
  21760. * @return the parent mesh
  21761. */
  21762. getMesh(): AbstractMesh;
  21763. /**
  21764. * Returns the rendering mesh of the submesh
  21765. * @returns the rendering mesh (could be different from parent mesh)
  21766. */
  21767. getRenderingMesh(): Mesh;
  21768. /**
  21769. * Returns the submesh material
  21770. * @returns null or the current material
  21771. */
  21772. getMaterial(): Nullable<Material>;
  21773. /**
  21774. * Sets a new updated BoundingInfo object to the submesh
  21775. * @param data defines an optional position array to use to determine the bounding info
  21776. * @returns the SubMesh
  21777. */
  21778. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21779. /** @hidden */
  21780. _checkCollision(collider: Collider): boolean;
  21781. /**
  21782. * Updates the submesh BoundingInfo
  21783. * @param world defines the world matrix to use to update the bounding info
  21784. * @returns the submesh
  21785. */
  21786. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21787. /**
  21788. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21789. * @param frustumPlanes defines the frustum planes
  21790. * @returns true if the submesh is intersecting with the frustum
  21791. */
  21792. isInFrustum(frustumPlanes: Plane[]): boolean;
  21793. /**
  21794. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21795. * @param frustumPlanes defines the frustum planes
  21796. * @returns true if the submesh is inside the frustum
  21797. */
  21798. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21799. /**
  21800. * Renders the submesh
  21801. * @param enableAlphaMode defines if alpha needs to be used
  21802. * @returns the submesh
  21803. */
  21804. render(enableAlphaMode: boolean): SubMesh;
  21805. /**
  21806. * @hidden
  21807. */
  21808. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21809. /**
  21810. * Checks if the submesh intersects with a ray
  21811. * @param ray defines the ray to test
  21812. * @returns true is the passed ray intersects the submesh bounding box
  21813. */
  21814. canIntersects(ray: Ray): boolean;
  21815. /**
  21816. * Intersects current submesh with a ray
  21817. * @param ray defines the ray to test
  21818. * @param positions defines mesh's positions array
  21819. * @param indices defines mesh's indices array
  21820. * @param fastCheck defines if only bounding info should be used
  21821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21822. * @returns intersection info or null if no intersection
  21823. */
  21824. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21825. /** @hidden */
  21826. private _intersectLines;
  21827. /** @hidden */
  21828. private _intersectUnIndexedLines;
  21829. /** @hidden */
  21830. private _intersectTriangles;
  21831. /** @hidden */
  21832. private _intersectUnIndexedTriangles;
  21833. /** @hidden */
  21834. _rebuild(): void;
  21835. /**
  21836. * Creates a new submesh from the passed mesh
  21837. * @param newMesh defines the new hosting mesh
  21838. * @param newRenderingMesh defines an optional rendering mesh
  21839. * @returns the new submesh
  21840. */
  21841. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21842. /**
  21843. * Release associated resources
  21844. */
  21845. dispose(): void;
  21846. /**
  21847. * Gets the class name
  21848. * @returns the string "SubMesh".
  21849. */
  21850. getClassName(): string;
  21851. /**
  21852. * Creates a new submesh from indices data
  21853. * @param materialIndex the index of the main mesh material
  21854. * @param startIndex the index where to start the copy in the mesh indices array
  21855. * @param indexCount the number of indices to copy then from the startIndex
  21856. * @param mesh the main mesh to create the submesh from
  21857. * @param renderingMesh the optional rendering mesh
  21858. * @returns a new submesh
  21859. */
  21860. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21861. }
  21862. }
  21863. declare module BABYLON {
  21864. /**
  21865. * Class used to represent data loading progression
  21866. */
  21867. export class SceneLoaderFlags {
  21868. private static _ForceFullSceneLoadingForIncremental;
  21869. private static _ShowLoadingScreen;
  21870. private static _CleanBoneMatrixWeights;
  21871. private static _loggingLevel;
  21872. /**
  21873. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21874. */
  21875. static get ForceFullSceneLoadingForIncremental(): boolean;
  21876. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21877. /**
  21878. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21879. */
  21880. static get ShowLoadingScreen(): boolean;
  21881. static set ShowLoadingScreen(value: boolean);
  21882. /**
  21883. * Defines the current logging level (while loading the scene)
  21884. * @ignorenaming
  21885. */
  21886. static get loggingLevel(): number;
  21887. static set loggingLevel(value: number);
  21888. /**
  21889. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21890. */
  21891. static get CleanBoneMatrixWeights(): boolean;
  21892. static set CleanBoneMatrixWeights(value: boolean);
  21893. }
  21894. }
  21895. declare module BABYLON {
  21896. /**
  21897. * Class used to store geometry data (vertex buffers + index buffer)
  21898. */
  21899. export class Geometry implements IGetSetVerticesData {
  21900. /**
  21901. * Gets or sets the ID of the geometry
  21902. */
  21903. id: string;
  21904. /**
  21905. * Gets or sets the unique ID of the geometry
  21906. */
  21907. uniqueId: number;
  21908. /**
  21909. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21910. */
  21911. delayLoadState: number;
  21912. /**
  21913. * Gets the file containing the data to load when running in delay load state
  21914. */
  21915. delayLoadingFile: Nullable<string>;
  21916. /**
  21917. * Callback called when the geometry is updated
  21918. */
  21919. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21920. private _scene;
  21921. private _engine;
  21922. private _meshes;
  21923. private _totalVertices;
  21924. /** @hidden */
  21925. _indices: IndicesArray;
  21926. /** @hidden */
  21927. _vertexBuffers: {
  21928. [key: string]: VertexBuffer;
  21929. };
  21930. private _isDisposed;
  21931. private _extend;
  21932. private _boundingBias;
  21933. /** @hidden */
  21934. _delayInfo: Array<string>;
  21935. private _indexBuffer;
  21936. private _indexBufferIsUpdatable;
  21937. /** @hidden */
  21938. _boundingInfo: Nullable<BoundingInfo>;
  21939. /** @hidden */
  21940. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21941. /** @hidden */
  21942. _softwareSkinningFrameId: number;
  21943. private _vertexArrayObjects;
  21944. private _updatable;
  21945. /** @hidden */
  21946. _positions: Nullable<Vector3[]>;
  21947. /**
  21948. * 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
  21949. */
  21950. get boundingBias(): Vector2;
  21951. /**
  21952. * 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
  21953. */
  21954. set boundingBias(value: Vector2);
  21955. /**
  21956. * Static function used to attach a new empty geometry to a mesh
  21957. * @param mesh defines the mesh to attach the geometry to
  21958. * @returns the new Geometry
  21959. */
  21960. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21961. /**
  21962. * Creates a new geometry
  21963. * @param id defines the unique ID
  21964. * @param scene defines the hosting scene
  21965. * @param vertexData defines the VertexData used to get geometry data
  21966. * @param updatable defines if geometry must be updatable (false by default)
  21967. * @param mesh defines the mesh that will be associated with the geometry
  21968. */
  21969. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21970. /**
  21971. * Gets the current extend of the geometry
  21972. */
  21973. get extend(): {
  21974. minimum: Vector3;
  21975. maximum: Vector3;
  21976. };
  21977. /**
  21978. * Gets the hosting scene
  21979. * @returns the hosting Scene
  21980. */
  21981. getScene(): Scene;
  21982. /**
  21983. * Gets the hosting engine
  21984. * @returns the hosting Engine
  21985. */
  21986. getEngine(): Engine;
  21987. /**
  21988. * Defines if the geometry is ready to use
  21989. * @returns true if the geometry is ready to be used
  21990. */
  21991. isReady(): boolean;
  21992. /**
  21993. * Gets a value indicating that the geometry should not be serialized
  21994. */
  21995. get doNotSerialize(): boolean;
  21996. /** @hidden */
  21997. _rebuild(): void;
  21998. /**
  21999. * Affects all geometry data in one call
  22000. * @param vertexData defines the geometry data
  22001. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22002. */
  22003. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22004. /**
  22005. * Set specific vertex data
  22006. * @param kind defines the data kind (Position, normal, etc...)
  22007. * @param data defines the vertex data to use
  22008. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22009. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22010. */
  22011. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22012. /**
  22013. * Removes a specific vertex data
  22014. * @param kind defines the data kind (Position, normal, etc...)
  22015. */
  22016. removeVerticesData(kind: string): void;
  22017. /**
  22018. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22019. * @param buffer defines the vertex buffer to use
  22020. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22021. */
  22022. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22023. /**
  22024. * Update a specific vertex buffer
  22025. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22026. * It will do nothing if the buffer is not updatable
  22027. * @param kind defines the data kind (Position, normal, etc...)
  22028. * @param data defines the data to use
  22029. * @param offset defines the offset in the target buffer where to store the data
  22030. * @param useBytes set to true if the offset is in bytes
  22031. */
  22032. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22033. /**
  22034. * Update a specific vertex buffer
  22035. * This function will create a new buffer if the current one is not updatable
  22036. * @param kind defines the data kind (Position, normal, etc...)
  22037. * @param data defines the data to use
  22038. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22039. */
  22040. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22041. private _updateBoundingInfo;
  22042. /** @hidden */
  22043. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22044. /**
  22045. * Gets total number of vertices
  22046. * @returns the total number of vertices
  22047. */
  22048. getTotalVertices(): number;
  22049. /**
  22050. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22051. * @param kind defines the data kind (Position, normal, etc...)
  22052. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22053. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22054. * @returns a float array containing vertex data
  22055. */
  22056. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22057. /**
  22058. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22059. * @param kind defines the data kind (Position, normal, etc...)
  22060. * @returns true if the vertex buffer with the specified kind is updatable
  22061. */
  22062. isVertexBufferUpdatable(kind: string): boolean;
  22063. /**
  22064. * Gets a specific vertex buffer
  22065. * @param kind defines the data kind (Position, normal, etc...)
  22066. * @returns a VertexBuffer
  22067. */
  22068. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22069. /**
  22070. * Returns all vertex buffers
  22071. * @return an object holding all vertex buffers indexed by kind
  22072. */
  22073. getVertexBuffers(): Nullable<{
  22074. [key: string]: VertexBuffer;
  22075. }>;
  22076. /**
  22077. * Gets a boolean indicating if specific vertex buffer is present
  22078. * @param kind defines the data kind (Position, normal, etc...)
  22079. * @returns true if data is present
  22080. */
  22081. isVerticesDataPresent(kind: string): boolean;
  22082. /**
  22083. * Gets a list of all attached data kinds (Position, normal, etc...)
  22084. * @returns a list of string containing all kinds
  22085. */
  22086. getVerticesDataKinds(): string[];
  22087. /**
  22088. * Update index buffer
  22089. * @param indices defines the indices to store in the index buffer
  22090. * @param offset defines the offset in the target buffer where to store the data
  22091. * @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)
  22092. */
  22093. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22094. /**
  22095. * Creates a new index buffer
  22096. * @param indices defines the indices to store in the index buffer
  22097. * @param totalVertices defines the total number of vertices (could be null)
  22098. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22099. */
  22100. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22101. /**
  22102. * Return the total number of indices
  22103. * @returns the total number of indices
  22104. */
  22105. getTotalIndices(): number;
  22106. /**
  22107. * Gets the index buffer array
  22108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22110. * @returns the index buffer array
  22111. */
  22112. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22113. /**
  22114. * Gets the index buffer
  22115. * @return the index buffer
  22116. */
  22117. getIndexBuffer(): Nullable<DataBuffer>;
  22118. /** @hidden */
  22119. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22120. /**
  22121. * Release the associated resources for a specific mesh
  22122. * @param mesh defines the source mesh
  22123. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22124. */
  22125. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22126. /**
  22127. * Apply current geometry to a given mesh
  22128. * @param mesh defines the mesh to apply geometry to
  22129. */
  22130. applyToMesh(mesh: Mesh): void;
  22131. private _updateExtend;
  22132. private _applyToMesh;
  22133. private notifyUpdate;
  22134. /**
  22135. * Load the geometry if it was flagged as delay loaded
  22136. * @param scene defines the hosting scene
  22137. * @param onLoaded defines a callback called when the geometry is loaded
  22138. */
  22139. load(scene: Scene, onLoaded?: () => void): void;
  22140. private _queueLoad;
  22141. /**
  22142. * Invert the geometry to move from a right handed system to a left handed one.
  22143. */
  22144. toLeftHanded(): void;
  22145. /** @hidden */
  22146. _resetPointsArrayCache(): void;
  22147. /** @hidden */
  22148. _generatePointsArray(): boolean;
  22149. /**
  22150. * Gets a value indicating if the geometry is disposed
  22151. * @returns true if the geometry was disposed
  22152. */
  22153. isDisposed(): boolean;
  22154. private _disposeVertexArrayObjects;
  22155. /**
  22156. * Free all associated resources
  22157. */
  22158. dispose(): void;
  22159. /**
  22160. * Clone the current geometry into a new geometry
  22161. * @param id defines the unique ID of the new geometry
  22162. * @returns a new geometry object
  22163. */
  22164. copy(id: string): Geometry;
  22165. /**
  22166. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22167. * @return a JSON representation of the current geometry data (without the vertices data)
  22168. */
  22169. serialize(): any;
  22170. private toNumberArray;
  22171. /**
  22172. * Serialize all vertices data into a JSON oject
  22173. * @returns a JSON representation of the current geometry data
  22174. */
  22175. serializeVerticeData(): any;
  22176. /**
  22177. * Extracts a clone of a mesh geometry
  22178. * @param mesh defines the source mesh
  22179. * @param id defines the unique ID of the new geometry object
  22180. * @returns the new geometry object
  22181. */
  22182. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22183. /**
  22184. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22185. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22186. * Be aware Math.random() could cause collisions, but:
  22187. * "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"
  22188. * @returns a string containing a new GUID
  22189. */
  22190. static RandomId(): string;
  22191. /** @hidden */
  22192. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22193. private static _CleanMatricesWeights;
  22194. /**
  22195. * Create a new geometry from persisted data (Using .babylon file format)
  22196. * @param parsedVertexData defines the persisted data
  22197. * @param scene defines the hosting scene
  22198. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22199. * @returns the new geometry object
  22200. */
  22201. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22202. }
  22203. }
  22204. declare module BABYLON {
  22205. /**
  22206. * Define an interface for all classes that will get and set the data on vertices
  22207. */
  22208. export interface IGetSetVerticesData {
  22209. /**
  22210. * Gets a boolean indicating if specific vertex data is present
  22211. * @param kind defines the vertex data kind to use
  22212. * @returns true is data kind is present
  22213. */
  22214. isVerticesDataPresent(kind: string): boolean;
  22215. /**
  22216. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22217. * @param kind defines the data kind (Position, normal, etc...)
  22218. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22219. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22220. * @returns a float array containing vertex data
  22221. */
  22222. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22223. /**
  22224. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22225. * @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.
  22226. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22227. * @returns the indices array or an empty array if the mesh has no geometry
  22228. */
  22229. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22230. /**
  22231. * Set specific vertex data
  22232. * @param kind defines the data kind (Position, normal, etc...)
  22233. * @param data defines the vertex data to use
  22234. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22235. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22236. */
  22237. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22238. /**
  22239. * Update a specific associated vertex buffer
  22240. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22241. * - VertexBuffer.PositionKind
  22242. * - VertexBuffer.UVKind
  22243. * - VertexBuffer.UV2Kind
  22244. * - VertexBuffer.UV3Kind
  22245. * - VertexBuffer.UV4Kind
  22246. * - VertexBuffer.UV5Kind
  22247. * - VertexBuffer.UV6Kind
  22248. * - VertexBuffer.ColorKind
  22249. * - VertexBuffer.MatricesIndicesKind
  22250. * - VertexBuffer.MatricesIndicesExtraKind
  22251. * - VertexBuffer.MatricesWeightsKind
  22252. * - VertexBuffer.MatricesWeightsExtraKind
  22253. * @param data defines the data source
  22254. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22255. * @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)
  22256. */
  22257. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22258. /**
  22259. * Creates a new index buffer
  22260. * @param indices defines the indices to store in the index buffer
  22261. * @param totalVertices defines the total number of vertices (could be null)
  22262. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22263. */
  22264. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22265. }
  22266. /**
  22267. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22268. */
  22269. export class VertexData {
  22270. /**
  22271. * Mesh side orientation : usually the external or front surface
  22272. */
  22273. static readonly FRONTSIDE: number;
  22274. /**
  22275. * Mesh side orientation : usually the internal or back surface
  22276. */
  22277. static readonly BACKSIDE: number;
  22278. /**
  22279. * Mesh side orientation : both internal and external or front and back surfaces
  22280. */
  22281. static readonly DOUBLESIDE: number;
  22282. /**
  22283. * Mesh side orientation : by default, `FRONTSIDE`
  22284. */
  22285. static readonly DEFAULTSIDE: number;
  22286. /**
  22287. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22288. */
  22289. positions: Nullable<FloatArray>;
  22290. /**
  22291. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22292. */
  22293. normals: Nullable<FloatArray>;
  22294. /**
  22295. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22296. */
  22297. tangents: Nullable<FloatArray>;
  22298. /**
  22299. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22300. */
  22301. uvs: Nullable<FloatArray>;
  22302. /**
  22303. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22304. */
  22305. uvs2: Nullable<FloatArray>;
  22306. /**
  22307. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22308. */
  22309. uvs3: Nullable<FloatArray>;
  22310. /**
  22311. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22312. */
  22313. uvs4: Nullable<FloatArray>;
  22314. /**
  22315. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22316. */
  22317. uvs5: Nullable<FloatArray>;
  22318. /**
  22319. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22320. */
  22321. uvs6: Nullable<FloatArray>;
  22322. /**
  22323. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22324. */
  22325. colors: Nullable<FloatArray>;
  22326. /**
  22327. * 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).
  22328. */
  22329. matricesIndices: Nullable<FloatArray>;
  22330. /**
  22331. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22332. */
  22333. matricesWeights: Nullable<FloatArray>;
  22334. /**
  22335. * An array extending the number of possible indices
  22336. */
  22337. matricesIndicesExtra: Nullable<FloatArray>;
  22338. /**
  22339. * An array extending the number of possible weights when the number of indices is extended
  22340. */
  22341. matricesWeightsExtra: Nullable<FloatArray>;
  22342. /**
  22343. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22344. */
  22345. indices: Nullable<IndicesArray>;
  22346. /**
  22347. * Uses the passed data array to set the set the values for the specified kind of data
  22348. * @param data a linear array of floating numbers
  22349. * @param kind the type of data that is being set, eg positions, colors etc
  22350. */
  22351. set(data: FloatArray, kind: string): void;
  22352. /**
  22353. * Associates the vertexData to the passed Mesh.
  22354. * Sets it as updatable or not (default `false`)
  22355. * @param mesh the mesh the vertexData is applied to
  22356. * @param updatable when used and having the value true allows new data to update the vertexData
  22357. * @returns the VertexData
  22358. */
  22359. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22360. /**
  22361. * Associates the vertexData to the passed Geometry.
  22362. * Sets it as updatable or not (default `false`)
  22363. * @param geometry the geometry the vertexData is applied to
  22364. * @param updatable when used and having the value true allows new data to update the vertexData
  22365. * @returns VertexData
  22366. */
  22367. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22368. /**
  22369. * Updates the associated mesh
  22370. * @param mesh the mesh to be updated
  22371. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22372. * @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
  22373. * @returns VertexData
  22374. */
  22375. updateMesh(mesh: Mesh): VertexData;
  22376. /**
  22377. * Updates the associated geometry
  22378. * @param geometry the geometry to be updated
  22379. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22380. * @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
  22381. * @returns VertexData.
  22382. */
  22383. updateGeometry(geometry: Geometry): VertexData;
  22384. private _applyTo;
  22385. private _update;
  22386. /**
  22387. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22388. * @param matrix the transforming matrix
  22389. * @returns the VertexData
  22390. */
  22391. transform(matrix: Matrix): VertexData;
  22392. /**
  22393. * Merges the passed VertexData into the current one
  22394. * @param other the VertexData to be merged into the current one
  22395. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22396. * @returns the modified VertexData
  22397. */
  22398. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22399. private _mergeElement;
  22400. private _validate;
  22401. /**
  22402. * Serializes the VertexData
  22403. * @returns a serialized object
  22404. */
  22405. serialize(): any;
  22406. /**
  22407. * Extracts the vertexData from a mesh
  22408. * @param mesh the mesh from which to extract the VertexData
  22409. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22410. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22411. * @returns the object VertexData associated to the passed mesh
  22412. */
  22413. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22414. /**
  22415. * Extracts the vertexData from the geometry
  22416. * @param geometry the geometry from which to extract the VertexData
  22417. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22418. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22419. * @returns the object VertexData associated to the passed mesh
  22420. */
  22421. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22422. private static _ExtractFrom;
  22423. /**
  22424. * Creates the VertexData for a Ribbon
  22425. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22426. * * pathArray array of paths, each of which an array of successive Vector3
  22427. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22428. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22429. * * 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
  22430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22431. * * 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)
  22432. * * 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)
  22433. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22434. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22435. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22436. * @returns the VertexData of the ribbon
  22437. */
  22438. static CreateRibbon(options: {
  22439. pathArray: Vector3[][];
  22440. closeArray?: boolean;
  22441. closePath?: boolean;
  22442. offset?: number;
  22443. sideOrientation?: number;
  22444. frontUVs?: Vector4;
  22445. backUVs?: Vector4;
  22446. invertUV?: boolean;
  22447. uvs?: Vector2[];
  22448. colors?: Color4[];
  22449. }): VertexData;
  22450. /**
  22451. * Creates the VertexData for a box
  22452. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22453. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22454. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22455. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22456. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22457. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22458. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22460. * * 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)
  22461. * * 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)
  22462. * @returns the VertexData of the box
  22463. */
  22464. static CreateBox(options: {
  22465. size?: number;
  22466. width?: number;
  22467. height?: number;
  22468. depth?: number;
  22469. faceUV?: Vector4[];
  22470. faceColors?: Color4[];
  22471. sideOrientation?: number;
  22472. frontUVs?: Vector4;
  22473. backUVs?: Vector4;
  22474. }): VertexData;
  22475. /**
  22476. * Creates the VertexData for a tiled box
  22477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22478. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22479. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22480. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22482. * @returns the VertexData of the box
  22483. */
  22484. static CreateTiledBox(options: {
  22485. pattern?: number;
  22486. width?: number;
  22487. height?: number;
  22488. depth?: number;
  22489. tileSize?: number;
  22490. tileWidth?: number;
  22491. tileHeight?: number;
  22492. alignHorizontal?: number;
  22493. alignVertical?: number;
  22494. faceUV?: Vector4[];
  22495. faceColors?: Color4[];
  22496. sideOrientation?: number;
  22497. }): VertexData;
  22498. /**
  22499. * Creates the VertexData for a tiled plane
  22500. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22501. * * pattern a limited pattern arrangement depending on the number
  22502. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22503. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22504. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22506. * * 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)
  22507. * * 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)
  22508. * @returns the VertexData of the tiled plane
  22509. */
  22510. static CreateTiledPlane(options: {
  22511. pattern?: number;
  22512. tileSize?: number;
  22513. tileWidth?: number;
  22514. tileHeight?: number;
  22515. size?: number;
  22516. width?: number;
  22517. height?: number;
  22518. alignHorizontal?: number;
  22519. alignVertical?: number;
  22520. sideOrientation?: number;
  22521. frontUVs?: Vector4;
  22522. backUVs?: Vector4;
  22523. }): VertexData;
  22524. /**
  22525. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22526. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22527. * * segments sets the number of horizontal strips optional, default 32
  22528. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22529. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22530. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22531. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22532. * * 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
  22533. * * 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
  22534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22535. * * 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)
  22536. * * 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)
  22537. * @returns the VertexData of the ellipsoid
  22538. */
  22539. static CreateSphere(options: {
  22540. segments?: number;
  22541. diameter?: number;
  22542. diameterX?: number;
  22543. diameterY?: number;
  22544. diameterZ?: number;
  22545. arc?: number;
  22546. slice?: number;
  22547. sideOrientation?: number;
  22548. frontUVs?: Vector4;
  22549. backUVs?: Vector4;
  22550. }): VertexData;
  22551. /**
  22552. * Creates the VertexData for a cylinder, cone or prism
  22553. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22554. * * height sets the height (y direction) of the cylinder, optional, default 2
  22555. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22556. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22557. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22558. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22559. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22560. * * 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
  22561. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22562. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22563. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22564. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22566. * * 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)
  22567. * * 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)
  22568. * @returns the VertexData of the cylinder, cone or prism
  22569. */
  22570. static CreateCylinder(options: {
  22571. height?: number;
  22572. diameterTop?: number;
  22573. diameterBottom?: number;
  22574. diameter?: number;
  22575. tessellation?: number;
  22576. subdivisions?: number;
  22577. arc?: number;
  22578. faceColors?: Color4[];
  22579. faceUV?: Vector4[];
  22580. hasRings?: boolean;
  22581. enclose?: boolean;
  22582. sideOrientation?: number;
  22583. frontUVs?: Vector4;
  22584. backUVs?: Vector4;
  22585. }): VertexData;
  22586. /**
  22587. * Creates the VertexData for a torus
  22588. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22589. * * diameter the diameter of the torus, optional default 1
  22590. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22591. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22593. * * 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)
  22594. * * 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)
  22595. * @returns the VertexData of the torus
  22596. */
  22597. static CreateTorus(options: {
  22598. diameter?: number;
  22599. thickness?: number;
  22600. tessellation?: number;
  22601. sideOrientation?: number;
  22602. frontUVs?: Vector4;
  22603. backUVs?: Vector4;
  22604. }): VertexData;
  22605. /**
  22606. * Creates the VertexData of the LineSystem
  22607. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22608. * - lines an array of lines, each line being an array of successive Vector3
  22609. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22610. * @returns the VertexData of the LineSystem
  22611. */
  22612. static CreateLineSystem(options: {
  22613. lines: Vector3[][];
  22614. colors?: Nullable<Color4[][]>;
  22615. }): VertexData;
  22616. /**
  22617. * Create the VertexData for a DashedLines
  22618. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22619. * - points an array successive Vector3
  22620. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22621. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22622. * - dashNb the intended total number of dashes, optional, default 200
  22623. * @returns the VertexData for the DashedLines
  22624. */
  22625. static CreateDashedLines(options: {
  22626. points: Vector3[];
  22627. dashSize?: number;
  22628. gapSize?: number;
  22629. dashNb?: number;
  22630. }): VertexData;
  22631. /**
  22632. * Creates the VertexData for a Ground
  22633. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22634. * - width the width (x direction) of the ground, optional, default 1
  22635. * - height the height (z direction) of the ground, optional, default 1
  22636. * - subdivisions the number of subdivisions per side, optional, default 1
  22637. * @returns the VertexData of the Ground
  22638. */
  22639. static CreateGround(options: {
  22640. width?: number;
  22641. height?: number;
  22642. subdivisions?: number;
  22643. subdivisionsX?: number;
  22644. subdivisionsY?: number;
  22645. }): VertexData;
  22646. /**
  22647. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22648. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22649. * * xmin the ground minimum X coordinate, optional, default -1
  22650. * * zmin the ground minimum Z coordinate, optional, default -1
  22651. * * xmax the ground maximum X coordinate, optional, default 1
  22652. * * zmax the ground maximum Z coordinate, optional, default 1
  22653. * * 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}
  22654. * * 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}
  22655. * @returns the VertexData of the TiledGround
  22656. */
  22657. static CreateTiledGround(options: {
  22658. xmin: number;
  22659. zmin: number;
  22660. xmax: number;
  22661. zmax: number;
  22662. subdivisions?: {
  22663. w: number;
  22664. h: number;
  22665. };
  22666. precision?: {
  22667. w: number;
  22668. h: number;
  22669. };
  22670. }): VertexData;
  22671. /**
  22672. * Creates the VertexData of the Ground designed from a heightmap
  22673. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22674. * * width the width (x direction) of the ground
  22675. * * height the height (z direction) of the ground
  22676. * * subdivisions the number of subdivisions per side
  22677. * * minHeight the minimum altitude on the ground, optional, default 0
  22678. * * maxHeight the maximum altitude on the ground, optional default 1
  22679. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22680. * * buffer the array holding the image color data
  22681. * * bufferWidth the width of image
  22682. * * bufferHeight the height of image
  22683. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22684. * @returns the VertexData of the Ground designed from a heightmap
  22685. */
  22686. static CreateGroundFromHeightMap(options: {
  22687. width: number;
  22688. height: number;
  22689. subdivisions: number;
  22690. minHeight: number;
  22691. maxHeight: number;
  22692. colorFilter: Color3;
  22693. buffer: Uint8Array;
  22694. bufferWidth: number;
  22695. bufferHeight: number;
  22696. alphaFilter: number;
  22697. }): VertexData;
  22698. /**
  22699. * Creates the VertexData for a Plane
  22700. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22701. * * size sets the width and height of the plane to the value of size, optional default 1
  22702. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22703. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22705. * * 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)
  22706. * * 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)
  22707. * @returns the VertexData of the box
  22708. */
  22709. static CreatePlane(options: {
  22710. size?: number;
  22711. width?: number;
  22712. height?: number;
  22713. sideOrientation?: number;
  22714. frontUVs?: Vector4;
  22715. backUVs?: Vector4;
  22716. }): VertexData;
  22717. /**
  22718. * Creates the VertexData of the Disc or regular Polygon
  22719. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22720. * * radius the radius of the disc, optional default 0.5
  22721. * * tessellation the number of polygon sides, optional, default 64
  22722. * * 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
  22723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22724. * * 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)
  22725. * * 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)
  22726. * @returns the VertexData of the box
  22727. */
  22728. static CreateDisc(options: {
  22729. radius?: number;
  22730. tessellation?: number;
  22731. arc?: number;
  22732. sideOrientation?: number;
  22733. frontUVs?: Vector4;
  22734. backUVs?: Vector4;
  22735. }): VertexData;
  22736. /**
  22737. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22738. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22739. * @param polygon a mesh built from polygonTriangulation.build()
  22740. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22741. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22742. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22743. * @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)
  22744. * @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)
  22745. * @returns the VertexData of the Polygon
  22746. */
  22747. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22748. /**
  22749. * Creates the VertexData of the IcoSphere
  22750. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22751. * * radius the radius of the IcoSphere, optional default 1
  22752. * * radiusX allows stretching in the x direction, optional, default radius
  22753. * * radiusY allows stretching in the y direction, optional, default radius
  22754. * * radiusZ allows stretching in the z direction, optional, default radius
  22755. * * flat when true creates a flat shaded mesh, optional, default true
  22756. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22758. * * 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)
  22759. * * 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)
  22760. * @returns the VertexData of the IcoSphere
  22761. */
  22762. static CreateIcoSphere(options: {
  22763. radius?: number;
  22764. radiusX?: number;
  22765. radiusY?: number;
  22766. radiusZ?: number;
  22767. flat?: boolean;
  22768. subdivisions?: number;
  22769. sideOrientation?: number;
  22770. frontUVs?: Vector4;
  22771. backUVs?: Vector4;
  22772. }): VertexData;
  22773. /**
  22774. * Creates the VertexData for a Polyhedron
  22775. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22776. * * type provided types are:
  22777. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22778. * * 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)
  22779. * * size the size of the IcoSphere, optional default 1
  22780. * * sizeX allows stretching in the x direction, optional, default size
  22781. * * sizeY allows stretching in the y direction, optional, default size
  22782. * * sizeZ allows stretching in the z direction, optional, default size
  22783. * * 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
  22784. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22785. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22786. * * flat when true creates a flat shaded mesh, optional, default true
  22787. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22789. * * 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)
  22790. * * 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)
  22791. * @returns the VertexData of the Polyhedron
  22792. */
  22793. static CreatePolyhedron(options: {
  22794. type?: number;
  22795. size?: number;
  22796. sizeX?: number;
  22797. sizeY?: number;
  22798. sizeZ?: number;
  22799. custom?: any;
  22800. faceUV?: Vector4[];
  22801. faceColors?: Color4[];
  22802. flat?: boolean;
  22803. sideOrientation?: number;
  22804. frontUVs?: Vector4;
  22805. backUVs?: Vector4;
  22806. }): VertexData;
  22807. /**
  22808. * Creates the VertexData for a TorusKnot
  22809. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22810. * * radius the radius of the torus knot, optional, default 2
  22811. * * tube the thickness of the tube, optional, default 0.5
  22812. * * radialSegments the number of sides on each tube segments, optional, default 32
  22813. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22814. * * p the number of windings around the z axis, optional, default 2
  22815. * * q the number of windings around the x axis, optional, default 3
  22816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22817. * * 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)
  22818. * * 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)
  22819. * @returns the VertexData of the Torus Knot
  22820. */
  22821. static CreateTorusKnot(options: {
  22822. radius?: number;
  22823. tube?: number;
  22824. radialSegments?: number;
  22825. tubularSegments?: number;
  22826. p?: number;
  22827. q?: number;
  22828. sideOrientation?: number;
  22829. frontUVs?: Vector4;
  22830. backUVs?: Vector4;
  22831. }): VertexData;
  22832. /**
  22833. * Compute normals for given positions and indices
  22834. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22835. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22836. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22837. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22838. * * facetNormals : optional array of facet normals (vector3)
  22839. * * facetPositions : optional array of facet positions (vector3)
  22840. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22841. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22842. * * bInfo : optional bounding info, required for facetPartitioning computation
  22843. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22844. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22845. * * useRightHandedSystem: optional boolean to for right handed system computation
  22846. * * depthSort : optional boolean to enable the facet depth sort computation
  22847. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22848. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22849. */
  22850. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22851. facetNormals?: any;
  22852. facetPositions?: any;
  22853. facetPartitioning?: any;
  22854. ratio?: number;
  22855. bInfo?: any;
  22856. bbSize?: Vector3;
  22857. subDiv?: any;
  22858. useRightHandedSystem?: boolean;
  22859. depthSort?: boolean;
  22860. distanceTo?: Vector3;
  22861. depthSortedFacets?: any;
  22862. }): void;
  22863. /** @hidden */
  22864. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22865. /**
  22866. * Applies VertexData created from the imported parameters to the geometry
  22867. * @param parsedVertexData the parsed data from an imported file
  22868. * @param geometry the geometry to apply the VertexData to
  22869. */
  22870. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22871. }
  22872. }
  22873. declare module BABYLON {
  22874. /**
  22875. * Defines a target to use with MorphTargetManager
  22876. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22877. */
  22878. export class MorphTarget implements IAnimatable {
  22879. /** defines the name of the target */
  22880. name: string;
  22881. /**
  22882. * Gets or sets the list of animations
  22883. */
  22884. animations: Animation[];
  22885. private _scene;
  22886. private _positions;
  22887. private _normals;
  22888. private _tangents;
  22889. private _uvs;
  22890. private _influence;
  22891. private _uniqueId;
  22892. /**
  22893. * Observable raised when the influence changes
  22894. */
  22895. onInfluenceChanged: Observable<boolean>;
  22896. /** @hidden */
  22897. _onDataLayoutChanged: Observable<void>;
  22898. /**
  22899. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22900. */
  22901. get influence(): number;
  22902. set influence(influence: number);
  22903. /**
  22904. * Gets or sets the id of the morph Target
  22905. */
  22906. id: string;
  22907. private _animationPropertiesOverride;
  22908. /**
  22909. * Gets or sets the animation properties override
  22910. */
  22911. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22912. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22913. /**
  22914. * Creates a new MorphTarget
  22915. * @param name defines the name of the target
  22916. * @param influence defines the influence to use
  22917. * @param scene defines the scene the morphtarget belongs to
  22918. */
  22919. constructor(
  22920. /** defines the name of the target */
  22921. name: string, influence?: number, scene?: Nullable<Scene>);
  22922. /**
  22923. * Gets the unique ID of this manager
  22924. */
  22925. get uniqueId(): number;
  22926. /**
  22927. * Gets a boolean defining if the target contains position data
  22928. */
  22929. get hasPositions(): boolean;
  22930. /**
  22931. * Gets a boolean defining if the target contains normal data
  22932. */
  22933. get hasNormals(): boolean;
  22934. /**
  22935. * Gets a boolean defining if the target contains tangent data
  22936. */
  22937. get hasTangents(): boolean;
  22938. /**
  22939. * Gets a boolean defining if the target contains texture coordinates data
  22940. */
  22941. get hasUVs(): boolean;
  22942. /**
  22943. * Affects position data to this target
  22944. * @param data defines the position data to use
  22945. */
  22946. setPositions(data: Nullable<FloatArray>): void;
  22947. /**
  22948. * Gets the position data stored in this target
  22949. * @returns a FloatArray containing the position data (or null if not present)
  22950. */
  22951. getPositions(): Nullable<FloatArray>;
  22952. /**
  22953. * Affects normal data to this target
  22954. * @param data defines the normal data to use
  22955. */
  22956. setNormals(data: Nullable<FloatArray>): void;
  22957. /**
  22958. * Gets the normal data stored in this target
  22959. * @returns a FloatArray containing the normal data (or null if not present)
  22960. */
  22961. getNormals(): Nullable<FloatArray>;
  22962. /**
  22963. * Affects tangent data to this target
  22964. * @param data defines the tangent data to use
  22965. */
  22966. setTangents(data: Nullable<FloatArray>): void;
  22967. /**
  22968. * Gets the tangent data stored in this target
  22969. * @returns a FloatArray containing the tangent data (or null if not present)
  22970. */
  22971. getTangents(): Nullable<FloatArray>;
  22972. /**
  22973. * Affects texture coordinates data to this target
  22974. * @param data defines the texture coordinates data to use
  22975. */
  22976. setUVs(data: Nullable<FloatArray>): void;
  22977. /**
  22978. * Gets the texture coordinates data stored in this target
  22979. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22980. */
  22981. getUVs(): Nullable<FloatArray>;
  22982. /**
  22983. * Clone the current target
  22984. * @returns a new MorphTarget
  22985. */
  22986. clone(): MorphTarget;
  22987. /**
  22988. * Serializes the current target into a Serialization object
  22989. * @returns the serialized object
  22990. */
  22991. serialize(): any;
  22992. /**
  22993. * Returns the string "MorphTarget"
  22994. * @returns "MorphTarget"
  22995. */
  22996. getClassName(): string;
  22997. /**
  22998. * Creates a new target from serialized data
  22999. * @param serializationObject defines the serialized data to use
  23000. * @returns a new MorphTarget
  23001. */
  23002. static Parse(serializationObject: any): MorphTarget;
  23003. /**
  23004. * Creates a MorphTarget from mesh data
  23005. * @param mesh defines the source mesh
  23006. * @param name defines the name to use for the new target
  23007. * @param influence defines the influence to attach to the target
  23008. * @returns a new MorphTarget
  23009. */
  23010. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23011. }
  23012. }
  23013. declare module BABYLON {
  23014. /**
  23015. * This class is used to deform meshes using morphing between different targets
  23016. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23017. */
  23018. export class MorphTargetManager {
  23019. private _targets;
  23020. private _targetInfluenceChangedObservers;
  23021. private _targetDataLayoutChangedObservers;
  23022. private _activeTargets;
  23023. private _scene;
  23024. private _influences;
  23025. private _supportsNormals;
  23026. private _supportsTangents;
  23027. private _supportsUVs;
  23028. private _vertexCount;
  23029. private _uniqueId;
  23030. private _tempInfluences;
  23031. /**
  23032. * Gets or sets a boolean indicating if normals must be morphed
  23033. */
  23034. enableNormalMorphing: boolean;
  23035. /**
  23036. * Gets or sets a boolean indicating if tangents must be morphed
  23037. */
  23038. enableTangentMorphing: boolean;
  23039. /**
  23040. * Gets or sets a boolean indicating if UV must be morphed
  23041. */
  23042. enableUVMorphing: boolean;
  23043. /**
  23044. * Creates a new MorphTargetManager
  23045. * @param scene defines the current scene
  23046. */
  23047. constructor(scene?: Nullable<Scene>);
  23048. /**
  23049. * Gets the unique ID of this manager
  23050. */
  23051. get uniqueId(): number;
  23052. /**
  23053. * Gets the number of vertices handled by this manager
  23054. */
  23055. get vertexCount(): number;
  23056. /**
  23057. * Gets a boolean indicating if this manager supports morphing of normals
  23058. */
  23059. get supportsNormals(): boolean;
  23060. /**
  23061. * Gets a boolean indicating if this manager supports morphing of tangents
  23062. */
  23063. get supportsTangents(): boolean;
  23064. /**
  23065. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23066. */
  23067. get supportsUVs(): boolean;
  23068. /**
  23069. * Gets the number of targets stored in this manager
  23070. */
  23071. get numTargets(): number;
  23072. /**
  23073. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23074. */
  23075. get numInfluencers(): number;
  23076. /**
  23077. * Gets the list of influences (one per target)
  23078. */
  23079. get influences(): Float32Array;
  23080. /**
  23081. * Gets the active target at specified index. An active target is a target with an influence > 0
  23082. * @param index defines the index to check
  23083. * @returns the requested target
  23084. */
  23085. getActiveTarget(index: number): MorphTarget;
  23086. /**
  23087. * Gets the target at specified index
  23088. * @param index defines the index to check
  23089. * @returns the requested target
  23090. */
  23091. getTarget(index: number): MorphTarget;
  23092. /**
  23093. * Add a new target to this manager
  23094. * @param target defines the target to add
  23095. */
  23096. addTarget(target: MorphTarget): void;
  23097. /**
  23098. * Removes a target from the manager
  23099. * @param target defines the target to remove
  23100. */
  23101. removeTarget(target: MorphTarget): void;
  23102. /**
  23103. * Clone the current manager
  23104. * @returns a new MorphTargetManager
  23105. */
  23106. clone(): MorphTargetManager;
  23107. /**
  23108. * Serializes the current manager into a Serialization object
  23109. * @returns the serialized object
  23110. */
  23111. serialize(): any;
  23112. private _syncActiveTargets;
  23113. /**
  23114. * Syncrhonize the targets with all the meshes using this morph target manager
  23115. */
  23116. synchronize(): void;
  23117. /**
  23118. * Creates a new MorphTargetManager from serialized data
  23119. * @param serializationObject defines the serialized data
  23120. * @param scene defines the hosting scene
  23121. * @returns the new MorphTargetManager
  23122. */
  23123. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23124. }
  23125. }
  23126. declare module BABYLON {
  23127. /**
  23128. * Class used to represent a specific level of detail of a mesh
  23129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23130. */
  23131. export class MeshLODLevel {
  23132. /** Defines the distance where this level should start being displayed */
  23133. distance: number;
  23134. /** Defines the mesh to use to render this level */
  23135. mesh: Nullable<Mesh>;
  23136. /**
  23137. * Creates a new LOD level
  23138. * @param distance defines the distance where this level should star being displayed
  23139. * @param mesh defines the mesh to use to render this level
  23140. */
  23141. constructor(
  23142. /** Defines the distance where this level should start being displayed */
  23143. distance: number,
  23144. /** Defines the mesh to use to render this level */
  23145. mesh: Nullable<Mesh>);
  23146. }
  23147. }
  23148. declare module BABYLON {
  23149. /**
  23150. * Mesh representing the gorund
  23151. */
  23152. export class GroundMesh extends Mesh {
  23153. /** If octree should be generated */
  23154. generateOctree: boolean;
  23155. private _heightQuads;
  23156. /** @hidden */
  23157. _subdivisionsX: number;
  23158. /** @hidden */
  23159. _subdivisionsY: number;
  23160. /** @hidden */
  23161. _width: number;
  23162. /** @hidden */
  23163. _height: number;
  23164. /** @hidden */
  23165. _minX: number;
  23166. /** @hidden */
  23167. _maxX: number;
  23168. /** @hidden */
  23169. _minZ: number;
  23170. /** @hidden */
  23171. _maxZ: number;
  23172. constructor(name: string, scene: Scene);
  23173. /**
  23174. * "GroundMesh"
  23175. * @returns "GroundMesh"
  23176. */
  23177. getClassName(): string;
  23178. /**
  23179. * The minimum of x and y subdivisions
  23180. */
  23181. get subdivisions(): number;
  23182. /**
  23183. * X subdivisions
  23184. */
  23185. get subdivisionsX(): number;
  23186. /**
  23187. * Y subdivisions
  23188. */
  23189. get subdivisionsY(): number;
  23190. /**
  23191. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23192. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23193. * @param chunksCount the number of subdivisions for x and y
  23194. * @param octreeBlocksSize (Default: 32)
  23195. */
  23196. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23197. /**
  23198. * Returns a height (y) value in the Worl system :
  23199. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23200. * @param x x coordinate
  23201. * @param z z coordinate
  23202. * @returns the ground y position if (x, z) are outside the ground surface.
  23203. */
  23204. getHeightAtCoordinates(x: number, z: number): number;
  23205. /**
  23206. * Returns a normalized vector (Vector3) orthogonal to the ground
  23207. * at the ground coordinates (x, z) expressed in the World system.
  23208. * @param x x coordinate
  23209. * @param z z coordinate
  23210. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23211. */
  23212. getNormalAtCoordinates(x: number, z: number): Vector3;
  23213. /**
  23214. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23215. * at the ground coordinates (x, z) expressed in the World system.
  23216. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23217. * @param x x coordinate
  23218. * @param z z coordinate
  23219. * @param ref vector to store the result
  23220. * @returns the GroundMesh.
  23221. */
  23222. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23223. /**
  23224. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23225. * if the ground has been updated.
  23226. * This can be used in the render loop.
  23227. * @returns the GroundMesh.
  23228. */
  23229. updateCoordinateHeights(): GroundMesh;
  23230. private _getFacetAt;
  23231. private _initHeightQuads;
  23232. private _computeHeightQuads;
  23233. /**
  23234. * Serializes this ground mesh
  23235. * @param serializationObject object to write serialization to
  23236. */
  23237. serialize(serializationObject: any): void;
  23238. /**
  23239. * Parses a serialized ground mesh
  23240. * @param parsedMesh the serialized mesh
  23241. * @param scene the scene to create the ground mesh in
  23242. * @returns the created ground mesh
  23243. */
  23244. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23245. }
  23246. }
  23247. declare module BABYLON {
  23248. /**
  23249. * Interface for Physics-Joint data
  23250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23251. */
  23252. export interface PhysicsJointData {
  23253. /**
  23254. * The main pivot of the joint
  23255. */
  23256. mainPivot?: Vector3;
  23257. /**
  23258. * The connected pivot of the joint
  23259. */
  23260. connectedPivot?: Vector3;
  23261. /**
  23262. * The main axis of the joint
  23263. */
  23264. mainAxis?: Vector3;
  23265. /**
  23266. * The connected axis of the joint
  23267. */
  23268. connectedAxis?: Vector3;
  23269. /**
  23270. * The collision of the joint
  23271. */
  23272. collision?: boolean;
  23273. /**
  23274. * Native Oimo/Cannon/Energy data
  23275. */
  23276. nativeParams?: any;
  23277. }
  23278. /**
  23279. * This is a holder class for the physics joint created by the physics plugin
  23280. * It holds a set of functions to control the underlying joint
  23281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23282. */
  23283. export class PhysicsJoint {
  23284. /**
  23285. * The type of the physics joint
  23286. */
  23287. type: number;
  23288. /**
  23289. * The data for the physics joint
  23290. */
  23291. jointData: PhysicsJointData;
  23292. private _physicsJoint;
  23293. protected _physicsPlugin: IPhysicsEnginePlugin;
  23294. /**
  23295. * Initializes the physics joint
  23296. * @param type The type of the physics joint
  23297. * @param jointData The data for the physics joint
  23298. */
  23299. constructor(
  23300. /**
  23301. * The type of the physics joint
  23302. */
  23303. type: number,
  23304. /**
  23305. * The data for the physics joint
  23306. */
  23307. jointData: PhysicsJointData);
  23308. /**
  23309. * Gets the physics joint
  23310. */
  23311. get physicsJoint(): any;
  23312. /**
  23313. * Sets the physics joint
  23314. */
  23315. set physicsJoint(newJoint: any);
  23316. /**
  23317. * Sets the physics plugin
  23318. */
  23319. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23320. /**
  23321. * Execute a function that is physics-plugin specific.
  23322. * @param {Function} func the function that will be executed.
  23323. * It accepts two parameters: the physics world and the physics joint
  23324. */
  23325. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23326. /**
  23327. * Distance-Joint type
  23328. */
  23329. static DistanceJoint: number;
  23330. /**
  23331. * Hinge-Joint type
  23332. */
  23333. static HingeJoint: number;
  23334. /**
  23335. * Ball-and-Socket joint type
  23336. */
  23337. static BallAndSocketJoint: number;
  23338. /**
  23339. * Wheel-Joint type
  23340. */
  23341. static WheelJoint: number;
  23342. /**
  23343. * Slider-Joint type
  23344. */
  23345. static SliderJoint: number;
  23346. /**
  23347. * Prismatic-Joint type
  23348. */
  23349. static PrismaticJoint: number;
  23350. /**
  23351. * Universal-Joint type
  23352. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23353. */
  23354. static UniversalJoint: number;
  23355. /**
  23356. * Hinge-Joint 2 type
  23357. */
  23358. static Hinge2Joint: number;
  23359. /**
  23360. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23361. */
  23362. static PointToPointJoint: number;
  23363. /**
  23364. * Spring-Joint type
  23365. */
  23366. static SpringJoint: number;
  23367. /**
  23368. * Lock-Joint type
  23369. */
  23370. static LockJoint: number;
  23371. }
  23372. /**
  23373. * A class representing a physics distance joint
  23374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23375. */
  23376. export class DistanceJoint extends PhysicsJoint {
  23377. /**
  23378. *
  23379. * @param jointData The data for the Distance-Joint
  23380. */
  23381. constructor(jointData: DistanceJointData);
  23382. /**
  23383. * Update the predefined distance.
  23384. * @param maxDistance The maximum preferred distance
  23385. * @param minDistance The minimum preferred distance
  23386. */
  23387. updateDistance(maxDistance: number, minDistance?: number): void;
  23388. }
  23389. /**
  23390. * Represents a Motor-Enabled Joint
  23391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23392. */
  23393. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23394. /**
  23395. * Initializes the Motor-Enabled Joint
  23396. * @param type The type of the joint
  23397. * @param jointData The physica joint data for the joint
  23398. */
  23399. constructor(type: number, jointData: PhysicsJointData);
  23400. /**
  23401. * Set the motor values.
  23402. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23403. * @param force the force to apply
  23404. * @param maxForce max force for this motor.
  23405. */
  23406. setMotor(force?: number, maxForce?: number): void;
  23407. /**
  23408. * Set the motor's limits.
  23409. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23410. * @param upperLimit The upper limit of the motor
  23411. * @param lowerLimit The lower limit of the motor
  23412. */
  23413. setLimit(upperLimit: number, lowerLimit?: number): void;
  23414. }
  23415. /**
  23416. * This class represents a single physics Hinge-Joint
  23417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23418. */
  23419. export class HingeJoint extends MotorEnabledJoint {
  23420. /**
  23421. * Initializes the Hinge-Joint
  23422. * @param jointData The joint data for the Hinge-Joint
  23423. */
  23424. constructor(jointData: PhysicsJointData);
  23425. /**
  23426. * Set the motor values.
  23427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23428. * @param {number} force the force to apply
  23429. * @param {number} maxForce max force for this motor.
  23430. */
  23431. setMotor(force?: number, maxForce?: number): void;
  23432. /**
  23433. * Set the motor's limits.
  23434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23435. * @param upperLimit The upper limit of the motor
  23436. * @param lowerLimit The lower limit of the motor
  23437. */
  23438. setLimit(upperLimit: number, lowerLimit?: number): void;
  23439. }
  23440. /**
  23441. * This class represents a dual hinge physics joint (same as wheel joint)
  23442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23443. */
  23444. export class Hinge2Joint extends MotorEnabledJoint {
  23445. /**
  23446. * Initializes the Hinge2-Joint
  23447. * @param jointData The joint data for the Hinge2-Joint
  23448. */
  23449. constructor(jointData: PhysicsJointData);
  23450. /**
  23451. * Set the motor values.
  23452. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23453. * @param {number} targetSpeed the speed the motor is to reach
  23454. * @param {number} maxForce max force for this motor.
  23455. * @param {motorIndex} the motor's index, 0 or 1.
  23456. */
  23457. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23458. /**
  23459. * Set the motor limits.
  23460. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23461. * @param {number} upperLimit the upper limit
  23462. * @param {number} lowerLimit lower limit
  23463. * @param {motorIndex} the motor's index, 0 or 1.
  23464. */
  23465. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23466. }
  23467. /**
  23468. * Interface for a motor enabled joint
  23469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23470. */
  23471. export interface IMotorEnabledJoint {
  23472. /**
  23473. * Physics joint
  23474. */
  23475. physicsJoint: any;
  23476. /**
  23477. * Sets the motor of the motor-enabled joint
  23478. * @param force The force of the motor
  23479. * @param maxForce The maximum force of the motor
  23480. * @param motorIndex The index of the motor
  23481. */
  23482. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23483. /**
  23484. * Sets the limit of the motor
  23485. * @param upperLimit The upper limit of the motor
  23486. * @param lowerLimit The lower limit of the motor
  23487. * @param motorIndex The index of the motor
  23488. */
  23489. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23490. }
  23491. /**
  23492. * Joint data for a Distance-Joint
  23493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23494. */
  23495. export interface DistanceJointData extends PhysicsJointData {
  23496. /**
  23497. * Max distance the 2 joint objects can be apart
  23498. */
  23499. maxDistance: number;
  23500. }
  23501. /**
  23502. * Joint data from a spring joint
  23503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23504. */
  23505. export interface SpringJointData extends PhysicsJointData {
  23506. /**
  23507. * Length of the spring
  23508. */
  23509. length: number;
  23510. /**
  23511. * Stiffness of the spring
  23512. */
  23513. stiffness: number;
  23514. /**
  23515. * Damping of the spring
  23516. */
  23517. damping: number;
  23518. /** this callback will be called when applying the force to the impostors. */
  23519. forceApplicationCallback: () => void;
  23520. }
  23521. }
  23522. declare module BABYLON {
  23523. /**
  23524. * Holds the data for the raycast result
  23525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23526. */
  23527. export class PhysicsRaycastResult {
  23528. private _hasHit;
  23529. private _hitDistance;
  23530. private _hitNormalWorld;
  23531. private _hitPointWorld;
  23532. private _rayFromWorld;
  23533. private _rayToWorld;
  23534. /**
  23535. * Gets if there was a hit
  23536. */
  23537. get hasHit(): boolean;
  23538. /**
  23539. * Gets the distance from the hit
  23540. */
  23541. get hitDistance(): number;
  23542. /**
  23543. * Gets the hit normal/direction in the world
  23544. */
  23545. get hitNormalWorld(): Vector3;
  23546. /**
  23547. * Gets the hit point in the world
  23548. */
  23549. get hitPointWorld(): Vector3;
  23550. /**
  23551. * Gets the ray "start point" of the ray in the world
  23552. */
  23553. get rayFromWorld(): Vector3;
  23554. /**
  23555. * Gets the ray "end point" of the ray in the world
  23556. */
  23557. get rayToWorld(): Vector3;
  23558. /**
  23559. * Sets the hit data (normal & point in world space)
  23560. * @param hitNormalWorld defines the normal in world space
  23561. * @param hitPointWorld defines the point in world space
  23562. */
  23563. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23564. /**
  23565. * Sets the distance from the start point to the hit point
  23566. * @param distance
  23567. */
  23568. setHitDistance(distance: number): void;
  23569. /**
  23570. * Calculates the distance manually
  23571. */
  23572. calculateHitDistance(): void;
  23573. /**
  23574. * Resets all the values to default
  23575. * @param from The from point on world space
  23576. * @param to The to point on world space
  23577. */
  23578. reset(from?: Vector3, to?: Vector3): void;
  23579. }
  23580. /**
  23581. * Interface for the size containing width and height
  23582. */
  23583. interface IXYZ {
  23584. /**
  23585. * X
  23586. */
  23587. x: number;
  23588. /**
  23589. * Y
  23590. */
  23591. y: number;
  23592. /**
  23593. * Z
  23594. */
  23595. z: number;
  23596. }
  23597. }
  23598. declare module BABYLON {
  23599. /**
  23600. * Interface used to describe a physics joint
  23601. */
  23602. export interface PhysicsImpostorJoint {
  23603. /** Defines the main impostor to which the joint is linked */
  23604. mainImpostor: PhysicsImpostor;
  23605. /** Defines the impostor that is connected to the main impostor using this joint */
  23606. connectedImpostor: PhysicsImpostor;
  23607. /** Defines the joint itself */
  23608. joint: PhysicsJoint;
  23609. }
  23610. /** @hidden */
  23611. export interface IPhysicsEnginePlugin {
  23612. world: any;
  23613. name: string;
  23614. setGravity(gravity: Vector3): void;
  23615. setTimeStep(timeStep: number): void;
  23616. getTimeStep(): number;
  23617. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23618. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23619. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23620. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23621. removePhysicsBody(impostor: PhysicsImpostor): void;
  23622. generateJoint(joint: PhysicsImpostorJoint): void;
  23623. removeJoint(joint: PhysicsImpostorJoint): void;
  23624. isSupported(): boolean;
  23625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23626. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23627. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23628. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23629. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23630. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23631. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23632. getBodyMass(impostor: PhysicsImpostor): number;
  23633. getBodyFriction(impostor: PhysicsImpostor): number;
  23634. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23635. getBodyRestitution(impostor: PhysicsImpostor): number;
  23636. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23637. getBodyPressure?(impostor: PhysicsImpostor): number;
  23638. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23639. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23640. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23641. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23642. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23643. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23644. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23645. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23646. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23647. sleepBody(impostor: PhysicsImpostor): void;
  23648. wakeUpBody(impostor: PhysicsImpostor): void;
  23649. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23650. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23651. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23652. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23653. getRadius(impostor: PhysicsImpostor): number;
  23654. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23656. dispose(): void;
  23657. }
  23658. /**
  23659. * Interface used to define a physics engine
  23660. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23661. */
  23662. export interface IPhysicsEngine {
  23663. /**
  23664. * Gets the gravity vector used by the simulation
  23665. */
  23666. gravity: Vector3;
  23667. /**
  23668. * Sets the gravity vector used by the simulation
  23669. * @param gravity defines the gravity vector to use
  23670. */
  23671. setGravity(gravity: Vector3): void;
  23672. /**
  23673. * Set the time step of the physics engine.
  23674. * Default is 1/60.
  23675. * To slow it down, enter 1/600 for example.
  23676. * To speed it up, 1/30
  23677. * @param newTimeStep the new timestep to apply to this world.
  23678. */
  23679. setTimeStep(newTimeStep: number): void;
  23680. /**
  23681. * Get the time step of the physics engine.
  23682. * @returns the current time step
  23683. */
  23684. getTimeStep(): number;
  23685. /**
  23686. * Set the sub time step of the physics engine.
  23687. * Default is 0 meaning there is no sub steps
  23688. * To increase physics resolution precision, set a small value (like 1 ms)
  23689. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23690. */
  23691. setSubTimeStep(subTimeStep: number): void;
  23692. /**
  23693. * Get the sub time step of the physics engine.
  23694. * @returns the current sub time step
  23695. */
  23696. getSubTimeStep(): number;
  23697. /**
  23698. * Release all resources
  23699. */
  23700. dispose(): void;
  23701. /**
  23702. * Gets the name of the current physics plugin
  23703. * @returns the name of the plugin
  23704. */
  23705. getPhysicsPluginName(): string;
  23706. /**
  23707. * Adding a new impostor for the impostor tracking.
  23708. * This will be done by the impostor itself.
  23709. * @param impostor the impostor to add
  23710. */
  23711. addImpostor(impostor: PhysicsImpostor): void;
  23712. /**
  23713. * Remove an impostor from the engine.
  23714. * This impostor and its mesh will not longer be updated by the physics engine.
  23715. * @param impostor the impostor to remove
  23716. */
  23717. removeImpostor(impostor: PhysicsImpostor): void;
  23718. /**
  23719. * Add a joint to the physics engine
  23720. * @param mainImpostor defines the main impostor to which the joint is added.
  23721. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23722. * @param joint defines the joint that will connect both impostors.
  23723. */
  23724. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23725. /**
  23726. * Removes a joint from the simulation
  23727. * @param mainImpostor defines the impostor used with the joint
  23728. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23729. * @param joint defines the joint to remove
  23730. */
  23731. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23732. /**
  23733. * Gets the current plugin used to run the simulation
  23734. * @returns current plugin
  23735. */
  23736. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23737. /**
  23738. * Gets the list of physic impostors
  23739. * @returns an array of PhysicsImpostor
  23740. */
  23741. getImpostors(): Array<PhysicsImpostor>;
  23742. /**
  23743. * Gets the impostor for a physics enabled object
  23744. * @param object defines the object impersonated by the impostor
  23745. * @returns the PhysicsImpostor or null if not found
  23746. */
  23747. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23748. /**
  23749. * Gets the impostor for a physics body object
  23750. * @param body defines physics body used by the impostor
  23751. * @returns the PhysicsImpostor or null if not found
  23752. */
  23753. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23754. /**
  23755. * Does a raycast in the physics world
  23756. * @param from when should the ray start?
  23757. * @param to when should the ray end?
  23758. * @returns PhysicsRaycastResult
  23759. */
  23760. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23761. /**
  23762. * Called by the scene. No need to call it.
  23763. * @param delta defines the timespam between frames
  23764. */
  23765. _step(delta: number): void;
  23766. }
  23767. }
  23768. declare module BABYLON {
  23769. /**
  23770. * The interface for the physics imposter parameters
  23771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23772. */
  23773. export interface PhysicsImpostorParameters {
  23774. /**
  23775. * The mass of the physics imposter
  23776. */
  23777. mass: number;
  23778. /**
  23779. * The friction of the physics imposter
  23780. */
  23781. friction?: number;
  23782. /**
  23783. * The coefficient of restitution of the physics imposter
  23784. */
  23785. restitution?: number;
  23786. /**
  23787. * The native options of the physics imposter
  23788. */
  23789. nativeOptions?: any;
  23790. /**
  23791. * Specifies if the parent should be ignored
  23792. */
  23793. ignoreParent?: boolean;
  23794. /**
  23795. * Specifies if bi-directional transformations should be disabled
  23796. */
  23797. disableBidirectionalTransformation?: boolean;
  23798. /**
  23799. * The pressure inside the physics imposter, soft object only
  23800. */
  23801. pressure?: number;
  23802. /**
  23803. * The stiffness the physics imposter, soft object only
  23804. */
  23805. stiffness?: number;
  23806. /**
  23807. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23808. */
  23809. velocityIterations?: number;
  23810. /**
  23811. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23812. */
  23813. positionIterations?: number;
  23814. /**
  23815. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23816. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23817. * Add to fix multiple points
  23818. */
  23819. fixedPoints?: number;
  23820. /**
  23821. * The collision margin around a soft object
  23822. */
  23823. margin?: number;
  23824. /**
  23825. * The collision margin around a soft object
  23826. */
  23827. damping?: number;
  23828. /**
  23829. * The path for a rope based on an extrusion
  23830. */
  23831. path?: any;
  23832. /**
  23833. * The shape of an extrusion used for a rope based on an extrusion
  23834. */
  23835. shape?: any;
  23836. }
  23837. /**
  23838. * Interface for a physics-enabled object
  23839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23840. */
  23841. export interface IPhysicsEnabledObject {
  23842. /**
  23843. * The position of the physics-enabled object
  23844. */
  23845. position: Vector3;
  23846. /**
  23847. * The rotation of the physics-enabled object
  23848. */
  23849. rotationQuaternion: Nullable<Quaternion>;
  23850. /**
  23851. * The scale of the physics-enabled object
  23852. */
  23853. scaling: Vector3;
  23854. /**
  23855. * The rotation of the physics-enabled object
  23856. */
  23857. rotation?: Vector3;
  23858. /**
  23859. * The parent of the physics-enabled object
  23860. */
  23861. parent?: any;
  23862. /**
  23863. * The bounding info of the physics-enabled object
  23864. * @returns The bounding info of the physics-enabled object
  23865. */
  23866. getBoundingInfo(): BoundingInfo;
  23867. /**
  23868. * Computes the world matrix
  23869. * @param force Specifies if the world matrix should be computed by force
  23870. * @returns A world matrix
  23871. */
  23872. computeWorldMatrix(force: boolean): Matrix;
  23873. /**
  23874. * Gets the world matrix
  23875. * @returns A world matrix
  23876. */
  23877. getWorldMatrix?(): Matrix;
  23878. /**
  23879. * Gets the child meshes
  23880. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23881. * @returns An array of abstract meshes
  23882. */
  23883. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23884. /**
  23885. * Gets the vertex data
  23886. * @param kind The type of vertex data
  23887. * @returns A nullable array of numbers, or a float32 array
  23888. */
  23889. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23890. /**
  23891. * Gets the indices from the mesh
  23892. * @returns A nullable array of index arrays
  23893. */
  23894. getIndices?(): Nullable<IndicesArray>;
  23895. /**
  23896. * Gets the scene from the mesh
  23897. * @returns the indices array or null
  23898. */
  23899. getScene?(): Scene;
  23900. /**
  23901. * Gets the absolute position from the mesh
  23902. * @returns the absolute position
  23903. */
  23904. getAbsolutePosition(): Vector3;
  23905. /**
  23906. * Gets the absolute pivot point from the mesh
  23907. * @returns the absolute pivot point
  23908. */
  23909. getAbsolutePivotPoint(): Vector3;
  23910. /**
  23911. * Rotates the mesh
  23912. * @param axis The axis of rotation
  23913. * @param amount The amount of rotation
  23914. * @param space The space of the rotation
  23915. * @returns The rotation transform node
  23916. */
  23917. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23918. /**
  23919. * Translates the mesh
  23920. * @param axis The axis of translation
  23921. * @param distance The distance of translation
  23922. * @param space The space of the translation
  23923. * @returns The transform node
  23924. */
  23925. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23926. /**
  23927. * Sets the absolute position of the mesh
  23928. * @param absolutePosition The absolute position of the mesh
  23929. * @returns The transform node
  23930. */
  23931. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23932. /**
  23933. * Gets the class name of the mesh
  23934. * @returns The class name
  23935. */
  23936. getClassName(): string;
  23937. }
  23938. /**
  23939. * Represents a physics imposter
  23940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23941. */
  23942. export class PhysicsImpostor {
  23943. /**
  23944. * The physics-enabled object used as the physics imposter
  23945. */
  23946. object: IPhysicsEnabledObject;
  23947. /**
  23948. * The type of the physics imposter
  23949. */
  23950. type: number;
  23951. private _options;
  23952. private _scene?;
  23953. /**
  23954. * The default object size of the imposter
  23955. */
  23956. static DEFAULT_OBJECT_SIZE: Vector3;
  23957. /**
  23958. * The identity quaternion of the imposter
  23959. */
  23960. static IDENTITY_QUATERNION: Quaternion;
  23961. /** @hidden */
  23962. _pluginData: any;
  23963. private _physicsEngine;
  23964. private _physicsBody;
  23965. private _bodyUpdateRequired;
  23966. private _onBeforePhysicsStepCallbacks;
  23967. private _onAfterPhysicsStepCallbacks;
  23968. /** @hidden */
  23969. _onPhysicsCollideCallbacks: Array<{
  23970. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23971. otherImpostors: Array<PhysicsImpostor>;
  23972. }>;
  23973. private _deltaPosition;
  23974. private _deltaRotation;
  23975. private _deltaRotationConjugated;
  23976. /** @hidden */
  23977. _isFromLine: boolean;
  23978. private _parent;
  23979. private _isDisposed;
  23980. private static _tmpVecs;
  23981. private static _tmpQuat;
  23982. /**
  23983. * Specifies if the physics imposter is disposed
  23984. */
  23985. get isDisposed(): boolean;
  23986. /**
  23987. * Gets the mass of the physics imposter
  23988. */
  23989. get mass(): number;
  23990. set mass(value: number);
  23991. /**
  23992. * Gets the coefficient of friction
  23993. */
  23994. get friction(): number;
  23995. /**
  23996. * Sets the coefficient of friction
  23997. */
  23998. set friction(value: number);
  23999. /**
  24000. * Gets the coefficient of restitution
  24001. */
  24002. get restitution(): number;
  24003. /**
  24004. * Sets the coefficient of restitution
  24005. */
  24006. set restitution(value: number);
  24007. /**
  24008. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24009. */
  24010. get pressure(): number;
  24011. /**
  24012. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24013. */
  24014. set pressure(value: number);
  24015. /**
  24016. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24017. */
  24018. get stiffness(): number;
  24019. /**
  24020. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24021. */
  24022. set stiffness(value: number);
  24023. /**
  24024. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24025. */
  24026. get velocityIterations(): number;
  24027. /**
  24028. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24029. */
  24030. set velocityIterations(value: number);
  24031. /**
  24032. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24033. */
  24034. get positionIterations(): number;
  24035. /**
  24036. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24037. */
  24038. set positionIterations(value: number);
  24039. /**
  24040. * The unique id of the physics imposter
  24041. * set by the physics engine when adding this impostor to the array
  24042. */
  24043. uniqueId: number;
  24044. /**
  24045. * @hidden
  24046. */
  24047. soft: boolean;
  24048. /**
  24049. * @hidden
  24050. */
  24051. segments: number;
  24052. private _joints;
  24053. /**
  24054. * Initializes the physics imposter
  24055. * @param object The physics-enabled object used as the physics imposter
  24056. * @param type The type of the physics imposter
  24057. * @param _options The options for the physics imposter
  24058. * @param _scene The Babylon scene
  24059. */
  24060. constructor(
  24061. /**
  24062. * The physics-enabled object used as the physics imposter
  24063. */
  24064. object: IPhysicsEnabledObject,
  24065. /**
  24066. * The type of the physics imposter
  24067. */
  24068. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24069. /**
  24070. * This function will completly initialize this impostor.
  24071. * It will create a new body - but only if this mesh has no parent.
  24072. * If it has, this impostor will not be used other than to define the impostor
  24073. * of the child mesh.
  24074. * @hidden
  24075. */
  24076. _init(): void;
  24077. private _getPhysicsParent;
  24078. /**
  24079. * Should a new body be generated.
  24080. * @returns boolean specifying if body initialization is required
  24081. */
  24082. isBodyInitRequired(): boolean;
  24083. /**
  24084. * Sets the updated scaling
  24085. * @param updated Specifies if the scaling is updated
  24086. */
  24087. setScalingUpdated(): void;
  24088. /**
  24089. * Force a regeneration of this or the parent's impostor's body.
  24090. * Use under cautious - This will remove all joints already implemented.
  24091. */
  24092. forceUpdate(): void;
  24093. /**
  24094. * Gets the body that holds this impostor. Either its own, or its parent.
  24095. */
  24096. get physicsBody(): any;
  24097. /**
  24098. * Get the parent of the physics imposter
  24099. * @returns Physics imposter or null
  24100. */
  24101. get parent(): Nullable<PhysicsImpostor>;
  24102. /**
  24103. * Sets the parent of the physics imposter
  24104. */
  24105. set parent(value: Nullable<PhysicsImpostor>);
  24106. /**
  24107. * Set the physics body. Used mainly by the physics engine/plugin
  24108. */
  24109. set physicsBody(physicsBody: any);
  24110. /**
  24111. * Resets the update flags
  24112. */
  24113. resetUpdateFlags(): void;
  24114. /**
  24115. * Gets the object extend size
  24116. * @returns the object extend size
  24117. */
  24118. getObjectExtendSize(): Vector3;
  24119. /**
  24120. * Gets the object center
  24121. * @returns The object center
  24122. */
  24123. getObjectCenter(): Vector3;
  24124. /**
  24125. * Get a specific parameter from the options parameters
  24126. * @param paramName The object parameter name
  24127. * @returns The object parameter
  24128. */
  24129. getParam(paramName: string): any;
  24130. /**
  24131. * Sets a specific parameter in the options given to the physics plugin
  24132. * @param paramName The parameter name
  24133. * @param value The value of the parameter
  24134. */
  24135. setParam(paramName: string, value: number): void;
  24136. /**
  24137. * Specifically change the body's mass option. Won't recreate the physics body object
  24138. * @param mass The mass of the physics imposter
  24139. */
  24140. setMass(mass: number): void;
  24141. /**
  24142. * Gets the linear velocity
  24143. * @returns linear velocity or null
  24144. */
  24145. getLinearVelocity(): Nullable<Vector3>;
  24146. /**
  24147. * Sets the linear velocity
  24148. * @param velocity linear velocity or null
  24149. */
  24150. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24151. /**
  24152. * Gets the angular velocity
  24153. * @returns angular velocity or null
  24154. */
  24155. getAngularVelocity(): Nullable<Vector3>;
  24156. /**
  24157. * Sets the angular velocity
  24158. * @param velocity The velocity or null
  24159. */
  24160. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24161. /**
  24162. * Execute a function with the physics plugin native code
  24163. * Provide a function the will have two variables - the world object and the physics body object
  24164. * @param func The function to execute with the physics plugin native code
  24165. */
  24166. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24167. /**
  24168. * Register a function that will be executed before the physics world is stepping forward
  24169. * @param func The function to execute before the physics world is stepped forward
  24170. */
  24171. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24172. /**
  24173. * Unregister a function that will be executed before the physics world is stepping forward
  24174. * @param func The function to execute before the physics world is stepped forward
  24175. */
  24176. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24177. /**
  24178. * Register a function that will be executed after the physics step
  24179. * @param func The function to execute after physics step
  24180. */
  24181. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24182. /**
  24183. * Unregisters a function that will be executed after the physics step
  24184. * @param func The function to execute after physics step
  24185. */
  24186. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24187. /**
  24188. * register a function that will be executed when this impostor collides against a different body
  24189. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24190. * @param func Callback that is executed on collision
  24191. */
  24192. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24193. /**
  24194. * Unregisters the physics imposter on contact
  24195. * @param collideAgainst The physics object to collide against
  24196. * @param func Callback to execute on collision
  24197. */
  24198. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24199. private _tmpQuat;
  24200. private _tmpQuat2;
  24201. /**
  24202. * Get the parent rotation
  24203. * @returns The parent rotation
  24204. */
  24205. getParentsRotation(): Quaternion;
  24206. /**
  24207. * this function is executed by the physics engine.
  24208. */
  24209. beforeStep: () => void;
  24210. /**
  24211. * this function is executed by the physics engine
  24212. */
  24213. afterStep: () => void;
  24214. /**
  24215. * Legacy collision detection event support
  24216. */
  24217. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24218. /**
  24219. * event and body object due to cannon's event-based architecture.
  24220. */
  24221. onCollide: (e: {
  24222. body: any;
  24223. }) => void;
  24224. /**
  24225. * Apply a force
  24226. * @param force The force to apply
  24227. * @param contactPoint The contact point for the force
  24228. * @returns The physics imposter
  24229. */
  24230. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24231. /**
  24232. * Apply an impulse
  24233. * @param force The impulse force
  24234. * @param contactPoint The contact point for the impulse force
  24235. * @returns The physics imposter
  24236. */
  24237. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24238. /**
  24239. * A help function to create a joint
  24240. * @param otherImpostor A physics imposter used to create a joint
  24241. * @param jointType The type of joint
  24242. * @param jointData The data for the joint
  24243. * @returns The physics imposter
  24244. */
  24245. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24246. /**
  24247. * Add a joint to this impostor with a different impostor
  24248. * @param otherImpostor A physics imposter used to add a joint
  24249. * @param joint The joint to add
  24250. * @returns The physics imposter
  24251. */
  24252. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24253. /**
  24254. * Add an anchor to a cloth impostor
  24255. * @param otherImpostor rigid impostor to anchor to
  24256. * @param width ratio across width from 0 to 1
  24257. * @param height ratio up height from 0 to 1
  24258. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24259. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24260. * @returns impostor the soft imposter
  24261. */
  24262. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24263. /**
  24264. * Add a hook to a rope impostor
  24265. * @param otherImpostor rigid impostor to anchor to
  24266. * @param length ratio across rope from 0 to 1
  24267. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24269. * @returns impostor the rope imposter
  24270. */
  24271. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24272. /**
  24273. * Will keep this body still, in a sleep mode.
  24274. * @returns the physics imposter
  24275. */
  24276. sleep(): PhysicsImpostor;
  24277. /**
  24278. * Wake the body up.
  24279. * @returns The physics imposter
  24280. */
  24281. wakeUp(): PhysicsImpostor;
  24282. /**
  24283. * Clones the physics imposter
  24284. * @param newObject The physics imposter clones to this physics-enabled object
  24285. * @returns A nullable physics imposter
  24286. */
  24287. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24288. /**
  24289. * Disposes the physics imposter
  24290. */
  24291. dispose(): void;
  24292. /**
  24293. * Sets the delta position
  24294. * @param position The delta position amount
  24295. */
  24296. setDeltaPosition(position: Vector3): void;
  24297. /**
  24298. * Sets the delta rotation
  24299. * @param rotation The delta rotation amount
  24300. */
  24301. setDeltaRotation(rotation: Quaternion): void;
  24302. /**
  24303. * Gets the box size of the physics imposter and stores the result in the input parameter
  24304. * @param result Stores the box size
  24305. * @returns The physics imposter
  24306. */
  24307. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24308. /**
  24309. * Gets the radius of the physics imposter
  24310. * @returns Radius of the physics imposter
  24311. */
  24312. getRadius(): number;
  24313. /**
  24314. * Sync a bone with this impostor
  24315. * @param bone The bone to sync to the impostor.
  24316. * @param boneMesh The mesh that the bone is influencing.
  24317. * @param jointPivot The pivot of the joint / bone in local space.
  24318. * @param distToJoint Optional distance from the impostor to the joint.
  24319. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24320. */
  24321. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24322. /**
  24323. * Sync impostor to a bone
  24324. * @param bone The bone that the impostor will be synced to.
  24325. * @param boneMesh The mesh that the bone is influencing.
  24326. * @param jointPivot The pivot of the joint / bone in local space.
  24327. * @param distToJoint Optional distance from the impostor to the joint.
  24328. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24329. * @param boneAxis Optional vector3 axis the bone is aligned with
  24330. */
  24331. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24332. /**
  24333. * No-Imposter type
  24334. */
  24335. static NoImpostor: number;
  24336. /**
  24337. * Sphere-Imposter type
  24338. */
  24339. static SphereImpostor: number;
  24340. /**
  24341. * Box-Imposter type
  24342. */
  24343. static BoxImpostor: number;
  24344. /**
  24345. * Plane-Imposter type
  24346. */
  24347. static PlaneImpostor: number;
  24348. /**
  24349. * Mesh-imposter type
  24350. */
  24351. static MeshImpostor: number;
  24352. /**
  24353. * Capsule-Impostor type (Ammo.js plugin only)
  24354. */
  24355. static CapsuleImpostor: number;
  24356. /**
  24357. * Cylinder-Imposter type
  24358. */
  24359. static CylinderImpostor: number;
  24360. /**
  24361. * Particle-Imposter type
  24362. */
  24363. static ParticleImpostor: number;
  24364. /**
  24365. * Heightmap-Imposter type
  24366. */
  24367. static HeightmapImpostor: number;
  24368. /**
  24369. * ConvexHull-Impostor type (Ammo.js plugin only)
  24370. */
  24371. static ConvexHullImpostor: number;
  24372. /**
  24373. * Custom-Imposter type (Ammo.js plugin only)
  24374. */
  24375. static CustomImpostor: number;
  24376. /**
  24377. * Rope-Imposter type
  24378. */
  24379. static RopeImpostor: number;
  24380. /**
  24381. * Cloth-Imposter type
  24382. */
  24383. static ClothImpostor: number;
  24384. /**
  24385. * Softbody-Imposter type
  24386. */
  24387. static SoftbodyImpostor: number;
  24388. }
  24389. }
  24390. declare module BABYLON {
  24391. /**
  24392. * @hidden
  24393. **/
  24394. export class _CreationDataStorage {
  24395. closePath?: boolean;
  24396. closeArray?: boolean;
  24397. idx: number[];
  24398. dashSize: number;
  24399. gapSize: number;
  24400. path3D: Path3D;
  24401. pathArray: Vector3[][];
  24402. arc: number;
  24403. radius: number;
  24404. cap: number;
  24405. tessellation: number;
  24406. }
  24407. /**
  24408. * @hidden
  24409. **/
  24410. class _InstanceDataStorage {
  24411. visibleInstances: any;
  24412. batchCache: _InstancesBatch;
  24413. instancesBufferSize: number;
  24414. instancesBuffer: Nullable<Buffer>;
  24415. instancesData: Float32Array;
  24416. overridenInstanceCount: number;
  24417. isFrozen: boolean;
  24418. previousBatch: Nullable<_InstancesBatch>;
  24419. hardwareInstancedRendering: boolean;
  24420. sideOrientation: number;
  24421. manualUpdate: boolean;
  24422. }
  24423. /**
  24424. * @hidden
  24425. **/
  24426. export class _InstancesBatch {
  24427. mustReturn: boolean;
  24428. visibleInstances: Nullable<InstancedMesh[]>[];
  24429. renderSelf: boolean[];
  24430. hardwareInstancedRendering: boolean[];
  24431. }
  24432. /**
  24433. * Class used to represent renderable models
  24434. */
  24435. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24436. /**
  24437. * Mesh side orientation : usually the external or front surface
  24438. */
  24439. static readonly FRONTSIDE: number;
  24440. /**
  24441. * Mesh side orientation : usually the internal or back surface
  24442. */
  24443. static readonly BACKSIDE: number;
  24444. /**
  24445. * Mesh side orientation : both internal and external or front and back surfaces
  24446. */
  24447. static readonly DOUBLESIDE: number;
  24448. /**
  24449. * Mesh side orientation : by default, `FRONTSIDE`
  24450. */
  24451. static readonly DEFAULTSIDE: number;
  24452. /**
  24453. * Mesh cap setting : no cap
  24454. */
  24455. static readonly NO_CAP: number;
  24456. /**
  24457. * Mesh cap setting : one cap at the beginning of the mesh
  24458. */
  24459. static readonly CAP_START: number;
  24460. /**
  24461. * Mesh cap setting : one cap at the end of the mesh
  24462. */
  24463. static readonly CAP_END: number;
  24464. /**
  24465. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24466. */
  24467. static readonly CAP_ALL: number;
  24468. /**
  24469. * Mesh pattern setting : no flip or rotate
  24470. */
  24471. static readonly NO_FLIP: number;
  24472. /**
  24473. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24474. */
  24475. static readonly FLIP_TILE: number;
  24476. /**
  24477. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24478. */
  24479. static readonly ROTATE_TILE: number;
  24480. /**
  24481. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24482. */
  24483. static readonly FLIP_ROW: number;
  24484. /**
  24485. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24486. */
  24487. static readonly ROTATE_ROW: number;
  24488. /**
  24489. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24490. */
  24491. static readonly FLIP_N_ROTATE_TILE: number;
  24492. /**
  24493. * Mesh pattern setting : rotate pattern and rotate
  24494. */
  24495. static readonly FLIP_N_ROTATE_ROW: number;
  24496. /**
  24497. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24498. */
  24499. static readonly CENTER: number;
  24500. /**
  24501. * Mesh tile positioning : part tiles on left
  24502. */
  24503. static readonly LEFT: number;
  24504. /**
  24505. * Mesh tile positioning : part tiles on right
  24506. */
  24507. static readonly RIGHT: number;
  24508. /**
  24509. * Mesh tile positioning : part tiles on top
  24510. */
  24511. static readonly TOP: number;
  24512. /**
  24513. * Mesh tile positioning : part tiles on bottom
  24514. */
  24515. static readonly BOTTOM: number;
  24516. /**
  24517. * Gets the default side orientation.
  24518. * @param orientation the orientation to value to attempt to get
  24519. * @returns the default orientation
  24520. * @hidden
  24521. */
  24522. static _GetDefaultSideOrientation(orientation?: number): number;
  24523. private _internalMeshDataInfo;
  24524. /**
  24525. * An event triggered before rendering the mesh
  24526. */
  24527. get onBeforeRenderObservable(): Observable<Mesh>;
  24528. /**
  24529. * An event triggered before binding the mesh
  24530. */
  24531. get onBeforeBindObservable(): Observable<Mesh>;
  24532. /**
  24533. * An event triggered after rendering the mesh
  24534. */
  24535. get onAfterRenderObservable(): Observable<Mesh>;
  24536. /**
  24537. * An event triggered before drawing the mesh
  24538. */
  24539. get onBeforeDrawObservable(): Observable<Mesh>;
  24540. private _onBeforeDrawObserver;
  24541. /**
  24542. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24543. */
  24544. set onBeforeDraw(callback: () => void);
  24545. get hasInstances(): boolean;
  24546. /**
  24547. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24548. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24549. */
  24550. delayLoadState: number;
  24551. /**
  24552. * Gets the list of instances created from this mesh
  24553. * it is not supposed to be modified manually.
  24554. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24555. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24556. */
  24557. instances: InstancedMesh[];
  24558. /**
  24559. * Gets the file containing delay loading data for this mesh
  24560. */
  24561. delayLoadingFile: string;
  24562. /** @hidden */
  24563. _binaryInfo: any;
  24564. /**
  24565. * User defined function used to change how LOD level selection is done
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24567. */
  24568. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24569. /**
  24570. * Gets or sets the morph target manager
  24571. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24572. */
  24573. get morphTargetManager(): Nullable<MorphTargetManager>;
  24574. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24575. /** @hidden */
  24576. _creationDataStorage: Nullable<_CreationDataStorage>;
  24577. /** @hidden */
  24578. _geometry: Nullable<Geometry>;
  24579. /** @hidden */
  24580. _delayInfo: Array<string>;
  24581. /** @hidden */
  24582. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24583. /** @hidden */
  24584. _instanceDataStorage: _InstanceDataStorage;
  24585. private _effectiveMaterial;
  24586. /** @hidden */
  24587. _shouldGenerateFlatShading: boolean;
  24588. /** @hidden */
  24589. _originalBuilderSideOrientation: number;
  24590. /**
  24591. * Use this property to change the original side orientation defined at construction time
  24592. */
  24593. overrideMaterialSideOrientation: Nullable<number>;
  24594. /**
  24595. * Gets the source mesh (the one used to clone this one from)
  24596. */
  24597. get source(): Nullable<Mesh>;
  24598. /**
  24599. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24600. */
  24601. get isUnIndexed(): boolean;
  24602. set isUnIndexed(value: boolean);
  24603. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24604. get worldMatrixInstancedBuffer(): Float32Array;
  24605. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24606. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24607. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24608. /**
  24609. * @constructor
  24610. * @param name The value used by scene.getMeshByName() to do a lookup.
  24611. * @param scene The scene to add this mesh to.
  24612. * @param parent The parent of this mesh, if it has one
  24613. * @param source An optional Mesh from which geometry is shared, cloned.
  24614. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24615. * When false, achieved by calling a clone(), also passing False.
  24616. * This will make creation of children, recursive.
  24617. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24618. */
  24619. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24620. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24621. doNotInstantiate: boolean;
  24622. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24623. /**
  24624. * Gets the class name
  24625. * @returns the string "Mesh".
  24626. */
  24627. getClassName(): string;
  24628. /** @hidden */
  24629. get _isMesh(): boolean;
  24630. /**
  24631. * Returns a description of this mesh
  24632. * @param fullDetails define if full details about this mesh must be used
  24633. * @returns a descriptive string representing this mesh
  24634. */
  24635. toString(fullDetails?: boolean): string;
  24636. /** @hidden */
  24637. _unBindEffect(): void;
  24638. /**
  24639. * Gets a boolean indicating if this mesh has LOD
  24640. */
  24641. get hasLODLevels(): boolean;
  24642. /**
  24643. * Gets the list of MeshLODLevel associated with the current mesh
  24644. * @returns an array of MeshLODLevel
  24645. */
  24646. getLODLevels(): MeshLODLevel[];
  24647. private _sortLODLevels;
  24648. /**
  24649. * Add a mesh as LOD level triggered at the given distance.
  24650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24651. * @param distance The distance from the center of the object to show this level
  24652. * @param mesh The mesh to be added as LOD level (can be null)
  24653. * @return This mesh (for chaining)
  24654. */
  24655. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24656. /**
  24657. * Returns the LOD level mesh at the passed distance or null if not found.
  24658. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24659. * @param distance The distance from the center of the object to show this level
  24660. * @returns a Mesh or `null`
  24661. */
  24662. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24663. /**
  24664. * Remove a mesh from the LOD array
  24665. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24666. * @param mesh defines the mesh to be removed
  24667. * @return This mesh (for chaining)
  24668. */
  24669. removeLODLevel(mesh: Mesh): Mesh;
  24670. /**
  24671. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24672. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24673. * @param camera defines the camera to use to compute distance
  24674. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24675. * @return This mesh (for chaining)
  24676. */
  24677. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24678. /**
  24679. * Gets the mesh internal Geometry object
  24680. */
  24681. get geometry(): Nullable<Geometry>;
  24682. /**
  24683. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24684. * @returns the total number of vertices
  24685. */
  24686. getTotalVertices(): number;
  24687. /**
  24688. * Returns the content of an associated vertex buffer
  24689. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24690. * - VertexBuffer.PositionKind
  24691. * - VertexBuffer.UVKind
  24692. * - VertexBuffer.UV2Kind
  24693. * - VertexBuffer.UV3Kind
  24694. * - VertexBuffer.UV4Kind
  24695. * - VertexBuffer.UV5Kind
  24696. * - VertexBuffer.UV6Kind
  24697. * - VertexBuffer.ColorKind
  24698. * - VertexBuffer.MatricesIndicesKind
  24699. * - VertexBuffer.MatricesIndicesExtraKind
  24700. * - VertexBuffer.MatricesWeightsKind
  24701. * - VertexBuffer.MatricesWeightsExtraKind
  24702. * @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
  24703. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24704. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24705. */
  24706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24707. /**
  24708. * Returns the mesh VertexBuffer object from the requested `kind`
  24709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24710. * - VertexBuffer.PositionKind
  24711. * - VertexBuffer.NormalKind
  24712. * - VertexBuffer.UVKind
  24713. * - VertexBuffer.UV2Kind
  24714. * - VertexBuffer.UV3Kind
  24715. * - VertexBuffer.UV4Kind
  24716. * - VertexBuffer.UV5Kind
  24717. * - VertexBuffer.UV6Kind
  24718. * - VertexBuffer.ColorKind
  24719. * - VertexBuffer.MatricesIndicesKind
  24720. * - VertexBuffer.MatricesIndicesExtraKind
  24721. * - VertexBuffer.MatricesWeightsKind
  24722. * - VertexBuffer.MatricesWeightsExtraKind
  24723. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24724. */
  24725. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24726. /**
  24727. * Tests if a specific vertex buffer is associated with this mesh
  24728. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24729. * - VertexBuffer.PositionKind
  24730. * - VertexBuffer.NormalKind
  24731. * - VertexBuffer.UVKind
  24732. * - VertexBuffer.UV2Kind
  24733. * - VertexBuffer.UV3Kind
  24734. * - VertexBuffer.UV4Kind
  24735. * - VertexBuffer.UV5Kind
  24736. * - VertexBuffer.UV6Kind
  24737. * - VertexBuffer.ColorKind
  24738. * - VertexBuffer.MatricesIndicesKind
  24739. * - VertexBuffer.MatricesIndicesExtraKind
  24740. * - VertexBuffer.MatricesWeightsKind
  24741. * - VertexBuffer.MatricesWeightsExtraKind
  24742. * @returns a boolean
  24743. */
  24744. isVerticesDataPresent(kind: string): boolean;
  24745. /**
  24746. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24747. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24748. * - VertexBuffer.PositionKind
  24749. * - VertexBuffer.UVKind
  24750. * - VertexBuffer.UV2Kind
  24751. * - VertexBuffer.UV3Kind
  24752. * - VertexBuffer.UV4Kind
  24753. * - VertexBuffer.UV5Kind
  24754. * - VertexBuffer.UV6Kind
  24755. * - VertexBuffer.ColorKind
  24756. * - VertexBuffer.MatricesIndicesKind
  24757. * - VertexBuffer.MatricesIndicesExtraKind
  24758. * - VertexBuffer.MatricesWeightsKind
  24759. * - VertexBuffer.MatricesWeightsExtraKind
  24760. * @returns a boolean
  24761. */
  24762. isVertexBufferUpdatable(kind: string): boolean;
  24763. /**
  24764. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24765. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24766. * - VertexBuffer.PositionKind
  24767. * - VertexBuffer.NormalKind
  24768. * - VertexBuffer.UVKind
  24769. * - VertexBuffer.UV2Kind
  24770. * - VertexBuffer.UV3Kind
  24771. * - VertexBuffer.UV4Kind
  24772. * - VertexBuffer.UV5Kind
  24773. * - VertexBuffer.UV6Kind
  24774. * - VertexBuffer.ColorKind
  24775. * - VertexBuffer.MatricesIndicesKind
  24776. * - VertexBuffer.MatricesIndicesExtraKind
  24777. * - VertexBuffer.MatricesWeightsKind
  24778. * - VertexBuffer.MatricesWeightsExtraKind
  24779. * @returns an array of strings
  24780. */
  24781. getVerticesDataKinds(): string[];
  24782. /**
  24783. * Returns a positive integer : the total number of indices in this mesh geometry.
  24784. * @returns the numner of indices or zero if the mesh has no geometry.
  24785. */
  24786. getTotalIndices(): number;
  24787. /**
  24788. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24789. * @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.
  24790. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24791. * @returns the indices array or an empty array if the mesh has no geometry
  24792. */
  24793. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24794. get isBlocked(): boolean;
  24795. /**
  24796. * Determine if the current mesh is ready to be rendered
  24797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24798. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24799. * @returns true if all associated assets are ready (material, textures, shaders)
  24800. */
  24801. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24802. /**
  24803. * 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.
  24804. */
  24805. get areNormalsFrozen(): boolean;
  24806. /**
  24807. * 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.
  24808. * @returns the current mesh
  24809. */
  24810. freezeNormals(): Mesh;
  24811. /**
  24812. * 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
  24813. * @returns the current mesh
  24814. */
  24815. unfreezeNormals(): Mesh;
  24816. /**
  24817. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24818. */
  24819. set overridenInstanceCount(count: number);
  24820. /** @hidden */
  24821. _preActivate(): Mesh;
  24822. /** @hidden */
  24823. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24824. /** @hidden */
  24825. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24826. /**
  24827. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24828. * This means the mesh underlying bounding box and sphere are recomputed.
  24829. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24830. * @returns the current mesh
  24831. */
  24832. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24833. /** @hidden */
  24834. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24835. /**
  24836. * This function will subdivide the mesh into multiple submeshes
  24837. * @param count defines the expected number of submeshes
  24838. */
  24839. subdivide(count: number): void;
  24840. /**
  24841. * Copy a FloatArray into a specific associated vertex buffer
  24842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24843. * - VertexBuffer.PositionKind
  24844. * - VertexBuffer.UVKind
  24845. * - VertexBuffer.UV2Kind
  24846. * - VertexBuffer.UV3Kind
  24847. * - VertexBuffer.UV4Kind
  24848. * - VertexBuffer.UV5Kind
  24849. * - VertexBuffer.UV6Kind
  24850. * - VertexBuffer.ColorKind
  24851. * - VertexBuffer.MatricesIndicesKind
  24852. * - VertexBuffer.MatricesIndicesExtraKind
  24853. * - VertexBuffer.MatricesWeightsKind
  24854. * - VertexBuffer.MatricesWeightsExtraKind
  24855. * @param data defines the data source
  24856. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24857. * @param stride defines the data stride size (can be null)
  24858. * @returns the current mesh
  24859. */
  24860. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24861. /**
  24862. * Delete a vertex buffer associated with this mesh
  24863. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24864. * - VertexBuffer.PositionKind
  24865. * - VertexBuffer.UVKind
  24866. * - VertexBuffer.UV2Kind
  24867. * - VertexBuffer.UV3Kind
  24868. * - VertexBuffer.UV4Kind
  24869. * - VertexBuffer.UV5Kind
  24870. * - VertexBuffer.UV6Kind
  24871. * - VertexBuffer.ColorKind
  24872. * - VertexBuffer.MatricesIndicesKind
  24873. * - VertexBuffer.MatricesIndicesExtraKind
  24874. * - VertexBuffer.MatricesWeightsKind
  24875. * - VertexBuffer.MatricesWeightsExtraKind
  24876. */
  24877. removeVerticesData(kind: string): void;
  24878. /**
  24879. * Flags an associated vertex buffer as updatable
  24880. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24881. * - VertexBuffer.PositionKind
  24882. * - VertexBuffer.UVKind
  24883. * - VertexBuffer.UV2Kind
  24884. * - VertexBuffer.UV3Kind
  24885. * - VertexBuffer.UV4Kind
  24886. * - VertexBuffer.UV5Kind
  24887. * - VertexBuffer.UV6Kind
  24888. * - VertexBuffer.ColorKind
  24889. * - VertexBuffer.MatricesIndicesKind
  24890. * - VertexBuffer.MatricesIndicesExtraKind
  24891. * - VertexBuffer.MatricesWeightsKind
  24892. * - VertexBuffer.MatricesWeightsExtraKind
  24893. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24894. */
  24895. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24896. /**
  24897. * Sets the mesh global Vertex Buffer
  24898. * @param buffer defines the buffer to use
  24899. * @returns the current mesh
  24900. */
  24901. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24902. /**
  24903. * Update a specific associated vertex buffer
  24904. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24905. * - VertexBuffer.PositionKind
  24906. * - VertexBuffer.UVKind
  24907. * - VertexBuffer.UV2Kind
  24908. * - VertexBuffer.UV3Kind
  24909. * - VertexBuffer.UV4Kind
  24910. * - VertexBuffer.UV5Kind
  24911. * - VertexBuffer.UV6Kind
  24912. * - VertexBuffer.ColorKind
  24913. * - VertexBuffer.MatricesIndicesKind
  24914. * - VertexBuffer.MatricesIndicesExtraKind
  24915. * - VertexBuffer.MatricesWeightsKind
  24916. * - VertexBuffer.MatricesWeightsExtraKind
  24917. * @param data defines the data source
  24918. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24919. * @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)
  24920. * @returns the current mesh
  24921. */
  24922. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24923. /**
  24924. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24925. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24926. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24927. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24928. * @returns the current mesh
  24929. */
  24930. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24931. /**
  24932. * Creates a un-shared specific occurence of the geometry for the mesh.
  24933. * @returns the current mesh
  24934. */
  24935. makeGeometryUnique(): Mesh;
  24936. /**
  24937. * Set the index buffer of this mesh
  24938. * @param indices defines the source data
  24939. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24940. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24941. * @returns the current mesh
  24942. */
  24943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24944. /**
  24945. * Update the current index buffer
  24946. * @param indices defines the source data
  24947. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24948. * @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)
  24949. * @returns the current mesh
  24950. */
  24951. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24952. /**
  24953. * Invert the geometry to move from a right handed system to a left handed one.
  24954. * @returns the current mesh
  24955. */
  24956. toLeftHanded(): Mesh;
  24957. /** @hidden */
  24958. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24959. /** @hidden */
  24960. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24961. /**
  24962. * Registers for this mesh a javascript function called just before the rendering process
  24963. * @param func defines the function to call before rendering this mesh
  24964. * @returns the current mesh
  24965. */
  24966. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24967. /**
  24968. * Disposes a previously registered javascript function called before the rendering
  24969. * @param func defines the function to remove
  24970. * @returns the current mesh
  24971. */
  24972. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24973. /**
  24974. * Registers for this mesh a javascript function called just after the rendering is complete
  24975. * @param func defines the function to call after rendering this mesh
  24976. * @returns the current mesh
  24977. */
  24978. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24979. /**
  24980. * Disposes a previously registered javascript function called after the rendering.
  24981. * @param func defines the function to remove
  24982. * @returns the current mesh
  24983. */
  24984. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24985. /** @hidden */
  24986. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24987. /** @hidden */
  24988. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24989. /** @hidden */
  24990. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24991. /** @hidden */
  24992. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24993. /** @hidden */
  24994. _rebuild(): void;
  24995. /** @hidden */
  24996. _freeze(): void;
  24997. /** @hidden */
  24998. _unFreeze(): void;
  24999. /**
  25000. * 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
  25001. * @param subMesh defines the subMesh to render
  25002. * @param enableAlphaMode defines if alpha mode can be changed
  25003. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25004. * @returns the current mesh
  25005. */
  25006. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25007. private _onBeforeDraw;
  25008. /**
  25009. * Renormalize the mesh and patch it up if there are no weights
  25010. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25011. * However in the case of zero weights then we set just a single influence to 1.
  25012. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25013. */
  25014. cleanMatrixWeights(): void;
  25015. private normalizeSkinFourWeights;
  25016. private normalizeSkinWeightsAndExtra;
  25017. /**
  25018. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25019. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25020. * the user know there was an issue with importing the mesh
  25021. * @returns a validation object with skinned, valid and report string
  25022. */
  25023. validateSkinning(): {
  25024. skinned: boolean;
  25025. valid: boolean;
  25026. report: string;
  25027. };
  25028. /** @hidden */
  25029. _checkDelayState(): Mesh;
  25030. private _queueLoad;
  25031. /**
  25032. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25033. * A mesh is in the frustum if its bounding box intersects the frustum
  25034. * @param frustumPlanes defines the frustum to test
  25035. * @returns true if the mesh is in the frustum planes
  25036. */
  25037. isInFrustum(frustumPlanes: Plane[]): boolean;
  25038. /**
  25039. * Sets the mesh material by the material or multiMaterial `id` property
  25040. * @param id is a string identifying the material or the multiMaterial
  25041. * @returns the current mesh
  25042. */
  25043. setMaterialByID(id: string): Mesh;
  25044. /**
  25045. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25046. * @returns an array of IAnimatable
  25047. */
  25048. getAnimatables(): IAnimatable[];
  25049. /**
  25050. * Modifies the mesh geometry according to the passed transformation matrix.
  25051. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25052. * The mesh normals are modified using the same transformation.
  25053. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25054. * @param transform defines the transform matrix to use
  25055. * @see http://doc.babylonjs.com/resources/baking_transformations
  25056. * @returns the current mesh
  25057. */
  25058. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25059. /**
  25060. * Modifies the mesh geometry according to its own current World Matrix.
  25061. * The mesh World Matrix is then reset.
  25062. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25063. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25064. * @see http://doc.babylonjs.com/resources/baking_transformations
  25065. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25066. * @returns the current mesh
  25067. */
  25068. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25069. /** @hidden */
  25070. get _positions(): Nullable<Vector3[]>;
  25071. /** @hidden */
  25072. _resetPointsArrayCache(): Mesh;
  25073. /** @hidden */
  25074. _generatePointsArray(): boolean;
  25075. /**
  25076. * Returns a new Mesh object generated from the current mesh properties.
  25077. * This method must not get confused with createInstance()
  25078. * @param name is a string, the name given to the new mesh
  25079. * @param newParent can be any Node object (default `null`)
  25080. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25081. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25082. * @returns a new mesh
  25083. */
  25084. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25085. /**
  25086. * Releases resources associated with this mesh.
  25087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25089. */
  25090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25091. /** @hidden */
  25092. _disposeInstanceSpecificData(): void;
  25093. /**
  25094. * Modifies the mesh geometry according to a displacement map.
  25095. * 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.
  25096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25097. * @param url is a string, the URL from the image file is to be downloaded.
  25098. * @param minHeight is the lower limit of the displacement.
  25099. * @param maxHeight is the upper limit of the displacement.
  25100. * @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.
  25101. * @param uvOffset is an optional vector2 used to offset UV.
  25102. * @param uvScale is an optional vector2 used to scale UV.
  25103. * @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.
  25104. * @returns the Mesh.
  25105. */
  25106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25107. /**
  25108. * Modifies the mesh geometry according to a displacementMap buffer.
  25109. * 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.
  25110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25112. * @param heightMapWidth is the width of the buffer image.
  25113. * @param heightMapHeight is the height of the buffer image.
  25114. * @param minHeight is the lower limit of the displacement.
  25115. * @param maxHeight is the upper limit of the displacement.
  25116. * @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.
  25117. * @param uvOffset is an optional vector2 used to offset UV.
  25118. * @param uvScale is an optional vector2 used to scale UV.
  25119. * @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.
  25120. * @returns the Mesh.
  25121. */
  25122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25123. /**
  25124. * Modify the mesh to get a flat shading rendering.
  25125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25127. * @returns current mesh
  25128. */
  25129. convertToFlatShadedMesh(): Mesh;
  25130. /**
  25131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25132. * In other words, more vertices, no more indices and a single bigger VBO.
  25133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25134. * @returns current mesh
  25135. */
  25136. convertToUnIndexedMesh(): Mesh;
  25137. /**
  25138. * Inverses facet orientations.
  25139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25140. * @param flipNormals will also inverts the normals
  25141. * @returns current mesh
  25142. */
  25143. flipFaces(flipNormals?: boolean): Mesh;
  25144. /**
  25145. * Increase the number of facets and hence vertices in a mesh
  25146. * Vertex normals are interpolated from existing vertex normals
  25147. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25148. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25149. */
  25150. increaseVertices(numberPerEdge: number): void;
  25151. /**
  25152. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25153. * This will undo any application of covertToFlatShadedMesh
  25154. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25155. */
  25156. forceSharedVertices(): void;
  25157. /** @hidden */
  25158. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25159. /** @hidden */
  25160. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25161. /**
  25162. * Creates a new InstancedMesh object from the mesh model.
  25163. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25164. * @param name defines the name of the new instance
  25165. * @returns a new InstancedMesh
  25166. */
  25167. createInstance(name: string): InstancedMesh;
  25168. /**
  25169. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25170. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25171. * @returns the current mesh
  25172. */
  25173. synchronizeInstances(): Mesh;
  25174. /**
  25175. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25176. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25177. * This should be used together with the simplification to avoid disappearing triangles.
  25178. * @param successCallback an optional success callback to be called after the optimization finished.
  25179. * @returns the current mesh
  25180. */
  25181. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25182. /**
  25183. * Serialize current mesh
  25184. * @param serializationObject defines the object which will receive the serialization data
  25185. */
  25186. serialize(serializationObject: any): void;
  25187. /** @hidden */
  25188. _syncGeometryWithMorphTargetManager(): void;
  25189. /** @hidden */
  25190. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25191. /**
  25192. * Returns a new Mesh object parsed from the source provided.
  25193. * @param parsedMesh is the source
  25194. * @param scene defines the hosting scene
  25195. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25196. * @returns a new Mesh
  25197. */
  25198. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25199. /**
  25200. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25201. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25202. * @param name defines the name of the mesh to create
  25203. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25204. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25205. * @param closePath creates a seam between the first and the last points of each path of the path array
  25206. * @param offset is taken in account only if the `pathArray` is containing a single path
  25207. * @param scene defines the hosting scene
  25208. * @param updatable defines if the mesh must be flagged as updatable
  25209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25210. * @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)
  25211. * @returns a new Mesh
  25212. */
  25213. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25214. /**
  25215. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25216. * @param name defines the name of the mesh to create
  25217. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25218. * @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
  25219. * @param scene defines the hosting scene
  25220. * @param updatable defines if the mesh must be flagged as updatable
  25221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25222. * @returns a new Mesh
  25223. */
  25224. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25225. /**
  25226. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25227. * @param name defines the name of the mesh to create
  25228. * @param size sets the size (float) of each box side (default 1)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25235. /**
  25236. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25237. * @param name defines the name of the mesh to create
  25238. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25239. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25240. * @param scene defines the hosting scene
  25241. * @param updatable defines if the mesh must be flagged as updatable
  25242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25243. * @returns a new Mesh
  25244. */
  25245. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25246. /**
  25247. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25248. * @param name defines the name of the mesh to create
  25249. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25250. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25251. * @param scene defines the hosting scene
  25252. * @returns a new Mesh
  25253. */
  25254. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25255. /**
  25256. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25257. * @param name defines the name of the mesh to create
  25258. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25259. * @param diameterTop set the top cap diameter (floats, default 1)
  25260. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25261. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25262. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25263. * @param scene defines the hosting scene
  25264. * @param updatable defines if the mesh must be flagged as updatable
  25265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25266. * @returns a new Mesh
  25267. */
  25268. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25269. /**
  25270. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25271. * @param name defines the name of the mesh to create
  25272. * @param diameter sets the diameter size (float) of the torus (default 1)
  25273. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25274. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25275. * @param scene defines the hosting scene
  25276. * @param updatable defines if the mesh must be flagged as updatable
  25277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25278. * @returns a new Mesh
  25279. */
  25280. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25281. /**
  25282. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25283. * @param name defines the name of the mesh to create
  25284. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25285. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25286. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25287. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25288. * @param p the number of windings on X axis (positive integers, default 2)
  25289. * @param q the number of windings on Y axis (positive integers, default 3)
  25290. * @param scene defines the hosting scene
  25291. * @param updatable defines if the mesh must be flagged as updatable
  25292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25293. * @returns a new Mesh
  25294. */
  25295. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25296. /**
  25297. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25298. * @param name defines the name of the mesh to create
  25299. * @param points is an array successive Vector3
  25300. * @param scene defines the hosting scene
  25301. * @param updatable defines if the mesh must be flagged as updatable
  25302. * @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).
  25303. * @returns a new Mesh
  25304. */
  25305. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25306. /**
  25307. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25308. * @param name defines the name of the mesh to create
  25309. * @param points is an array successive Vector3
  25310. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25311. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25312. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25313. * @param scene defines the hosting scene
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @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)
  25316. * @returns a new Mesh
  25317. */
  25318. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25319. /**
  25320. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25321. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25322. * 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.
  25323. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25324. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25325. * Remember you can only change the shape positions, not their number when updating a polygon.
  25326. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25327. * @param name defines the name of the mesh to create
  25328. * @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
  25329. * @param scene defines the hosting scene
  25330. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25331. * @param updatable defines if the mesh must be flagged as updatable
  25332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25333. * @param earcutInjection can be used to inject your own earcut reference
  25334. * @returns a new Mesh
  25335. */
  25336. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25337. /**
  25338. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25339. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25340. * @param name defines the name of the mesh to create
  25341. * @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
  25342. * @param depth defines the height of extrusion
  25343. * @param scene defines the hosting scene
  25344. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25345. * @param updatable defines if the mesh must be flagged as updatable
  25346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25347. * @param earcutInjection can be used to inject your own earcut reference
  25348. * @returns a new Mesh
  25349. */
  25350. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25351. /**
  25352. * Creates an extruded shape mesh.
  25353. * 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
  25354. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25356. * @param name defines the name of the mesh to create
  25357. * @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
  25358. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25359. * @param scale is the value to scale the shape
  25360. * @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
  25361. * @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
  25362. * @param scene defines the hosting scene
  25363. * @param updatable defines if the mesh must be flagged as updatable
  25364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25365. * @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)
  25366. * @returns a new Mesh
  25367. */
  25368. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25369. /**
  25370. * Creates an custom extruded shape mesh.
  25371. * The custom extrusion is a parametric shape.
  25372. * It has no predefined shape. Its final shape will depend on the input parameters.
  25373. * Please consider using the same method from the MeshBuilder class instead
  25374. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25375. * @param name defines the name of the mesh to create
  25376. * @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
  25377. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25378. * @param scaleFunction is a custom Javascript function called on each path point
  25379. * @param rotationFunction is a custom Javascript function called on each path point
  25380. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25381. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25382. * @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
  25383. * @param scene defines the hosting scene
  25384. * @param updatable defines if the mesh must be flagged as updatable
  25385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25386. * @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)
  25387. * @returns a new Mesh
  25388. */
  25389. 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;
  25390. /**
  25391. * Creates lathe mesh.
  25392. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25393. * Please consider using the same method from the MeshBuilder class instead
  25394. * @param name defines the name of the mesh to create
  25395. * @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
  25396. * @param radius is the radius value of the lathe
  25397. * @param tessellation is the side number of the lathe.
  25398. * @param scene defines the hosting scene
  25399. * @param updatable defines if the mesh must be flagged as updatable
  25400. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25401. * @returns a new Mesh
  25402. */
  25403. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25404. /**
  25405. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25406. * @param name defines the name of the mesh to create
  25407. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25408. * @param scene defines the hosting scene
  25409. * @param updatable defines if the mesh must be flagged as updatable
  25410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25411. * @returns a new Mesh
  25412. */
  25413. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25414. /**
  25415. * Creates a ground mesh.
  25416. * Please consider using the same method from the MeshBuilder class instead
  25417. * @param name defines the name of the mesh to create
  25418. * @param width set the width of the ground
  25419. * @param height set the height of the ground
  25420. * @param subdivisions sets the number of subdivisions per side
  25421. * @param scene defines the hosting scene
  25422. * @param updatable defines if the mesh must be flagged as updatable
  25423. * @returns a new Mesh
  25424. */
  25425. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25426. /**
  25427. * Creates a tiled ground mesh.
  25428. * Please consider using the same method from the MeshBuilder class instead
  25429. * @param name defines the name of the mesh to create
  25430. * @param xmin set the ground minimum X coordinate
  25431. * @param zmin set the ground minimum Y coordinate
  25432. * @param xmax set the ground maximum X coordinate
  25433. * @param zmax set the ground maximum Z coordinate
  25434. * @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
  25435. * @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
  25436. * @param scene defines the hosting scene
  25437. * @param updatable defines if the mesh must be flagged as updatable
  25438. * @returns a new Mesh
  25439. */
  25440. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25441. w: number;
  25442. h: number;
  25443. }, precision: {
  25444. w: number;
  25445. h: number;
  25446. }, scene: Scene, updatable?: boolean): Mesh;
  25447. /**
  25448. * Creates a ground mesh from a height map.
  25449. * Please consider using the same method from the MeshBuilder class instead
  25450. * @see http://doc.babylonjs.com/babylon101/height_map
  25451. * @param name defines the name of the mesh to create
  25452. * @param url sets the URL of the height map image resource
  25453. * @param width set the ground width size
  25454. * @param height set the ground height size
  25455. * @param subdivisions sets the number of subdivision per side
  25456. * @param minHeight is the minimum altitude on the ground
  25457. * @param maxHeight is the maximum altitude on the ground
  25458. * @param scene defines the hosting scene
  25459. * @param updatable defines if the mesh must be flagged as updatable
  25460. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25461. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25462. * @returns a new Mesh
  25463. */
  25464. 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;
  25465. /**
  25466. * Creates a tube mesh.
  25467. * The tube is a parametric shape.
  25468. * It has no predefined shape. Its final shape will depend on the input parameters.
  25469. * Please consider using the same method from the MeshBuilder class instead
  25470. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25471. * @param name defines the name of the mesh to create
  25472. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25473. * @param radius sets the tube radius size
  25474. * @param tessellation is the number of sides on the tubular surface
  25475. * @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
  25476. * @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
  25477. * @param scene defines the hosting scene
  25478. * @param updatable defines if the mesh must be flagged as updatable
  25479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25480. * @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)
  25481. * @returns a new Mesh
  25482. */
  25483. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25484. (i: number, distance: number): number;
  25485. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25486. /**
  25487. * Creates a polyhedron mesh.
  25488. * Please consider using the same method from the MeshBuilder class instead.
  25489. * * 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
  25490. * * The parameter `size` (positive float, default 1) sets the polygon size
  25491. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25492. * * 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`
  25493. * * 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
  25494. * * 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)`)
  25495. * * 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
  25496. * * 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
  25497. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25498. * * 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
  25499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25500. * @param name defines the name of the mesh to create
  25501. * @param options defines the options used to create the mesh
  25502. * @param scene defines the hosting scene
  25503. * @returns a new Mesh
  25504. */
  25505. static CreatePolyhedron(name: string, options: {
  25506. type?: number;
  25507. size?: number;
  25508. sizeX?: number;
  25509. sizeY?: number;
  25510. sizeZ?: number;
  25511. custom?: any;
  25512. faceUV?: Vector4[];
  25513. faceColors?: Color4[];
  25514. updatable?: boolean;
  25515. sideOrientation?: number;
  25516. }, scene: Scene): Mesh;
  25517. /**
  25518. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25519. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25520. * * 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`)
  25521. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25522. * * 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
  25523. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25524. * * 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
  25525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25526. * @param name defines the name of the mesh
  25527. * @param options defines the options used to create the mesh
  25528. * @param scene defines the hosting scene
  25529. * @returns a new Mesh
  25530. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25531. */
  25532. static CreateIcoSphere(name: string, options: {
  25533. radius?: number;
  25534. flat?: boolean;
  25535. subdivisions?: number;
  25536. sideOrientation?: number;
  25537. updatable?: boolean;
  25538. }, scene: Scene): Mesh;
  25539. /**
  25540. * Creates a decal mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead.
  25542. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25543. * @param name defines the name of the mesh
  25544. * @param sourceMesh defines the mesh receiving the decal
  25545. * @param position sets the position of the decal in world coordinates
  25546. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25547. * @param size sets the decal scaling
  25548. * @param angle sets the angle to rotate the decal
  25549. * @returns a new Mesh
  25550. */
  25551. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25552. /**
  25553. * Prepare internal position array for software CPU skinning
  25554. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25555. */
  25556. setPositionsForCPUSkinning(): Float32Array;
  25557. /**
  25558. * Prepare internal normal array for software CPU skinning
  25559. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25560. */
  25561. setNormalsForCPUSkinning(): Float32Array;
  25562. /**
  25563. * Updates the vertex buffer by applying transformation from the bones
  25564. * @param skeleton defines the skeleton to apply to current mesh
  25565. * @returns the current mesh
  25566. */
  25567. applySkeleton(skeleton: Skeleton): Mesh;
  25568. /**
  25569. * 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
  25570. * @param meshes defines the list of meshes to scan
  25571. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25572. */
  25573. static MinMax(meshes: AbstractMesh[]): {
  25574. min: Vector3;
  25575. max: Vector3;
  25576. };
  25577. /**
  25578. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25579. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25580. * @returns a vector3
  25581. */
  25582. static Center(meshesOrMinMaxVector: {
  25583. min: Vector3;
  25584. max: Vector3;
  25585. } | AbstractMesh[]): Vector3;
  25586. /**
  25587. * Merge the array of meshes into a single mesh for performance reasons.
  25588. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25589. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25590. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25591. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25592. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25593. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25594. * @returns a new mesh
  25595. */
  25596. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25597. /** @hidden */
  25598. addInstance(instance: InstancedMesh): void;
  25599. /** @hidden */
  25600. removeInstance(instance: InstancedMesh): void;
  25601. }
  25602. }
  25603. declare module BABYLON {
  25604. /**
  25605. * This is the base class of all the camera used in the application.
  25606. * @see http://doc.babylonjs.com/features/cameras
  25607. */
  25608. export class Camera extends Node {
  25609. /** @hidden */
  25610. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25611. /**
  25612. * This is the default projection mode used by the cameras.
  25613. * It helps recreating a feeling of perspective and better appreciate depth.
  25614. * This is the best way to simulate real life cameras.
  25615. */
  25616. static readonly PERSPECTIVE_CAMERA: number;
  25617. /**
  25618. * This helps creating camera with an orthographic mode.
  25619. * 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.
  25620. */
  25621. static readonly ORTHOGRAPHIC_CAMERA: number;
  25622. /**
  25623. * This is the default FOV mode for perspective cameras.
  25624. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25625. */
  25626. static readonly FOVMODE_VERTICAL_FIXED: number;
  25627. /**
  25628. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25629. */
  25630. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25631. /**
  25632. * This specifies ther is no need for a camera rig.
  25633. * Basically only one eye is rendered corresponding to the camera.
  25634. */
  25635. static readonly RIG_MODE_NONE: number;
  25636. /**
  25637. * Simulates a camera Rig with one blue eye and one red eye.
  25638. * This can be use with 3d blue and red glasses.
  25639. */
  25640. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25641. /**
  25642. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25643. */
  25644. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25645. /**
  25646. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25647. */
  25648. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25649. /**
  25650. * Defines that both eyes of the camera will be rendered over under each other.
  25651. */
  25652. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25653. /**
  25654. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25655. */
  25656. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25657. /**
  25658. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25659. */
  25660. static readonly RIG_MODE_VR: number;
  25661. /**
  25662. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25663. */
  25664. static readonly RIG_MODE_WEBVR: number;
  25665. /**
  25666. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25667. */
  25668. static readonly RIG_MODE_CUSTOM: number;
  25669. /**
  25670. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25671. */
  25672. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25673. /**
  25674. * Define the input manager associated with the camera.
  25675. */
  25676. inputs: CameraInputsManager<Camera>;
  25677. /** @hidden */
  25678. _position: Vector3;
  25679. /**
  25680. * Define the current local position of the camera in the scene
  25681. */
  25682. get position(): Vector3;
  25683. set position(newPosition: Vector3);
  25684. /**
  25685. * The vector the camera should consider as up.
  25686. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25687. */
  25688. upVector: Vector3;
  25689. /**
  25690. * Define the current limit on the left side for an orthographic camera
  25691. * In scene unit
  25692. */
  25693. orthoLeft: Nullable<number>;
  25694. /**
  25695. * Define the current limit on the right side for an orthographic camera
  25696. * In scene unit
  25697. */
  25698. orthoRight: Nullable<number>;
  25699. /**
  25700. * Define the current limit on the bottom side for an orthographic camera
  25701. * In scene unit
  25702. */
  25703. orthoBottom: Nullable<number>;
  25704. /**
  25705. * Define the current limit on the top side for an orthographic camera
  25706. * In scene unit
  25707. */
  25708. orthoTop: Nullable<number>;
  25709. /**
  25710. * Field Of View is set in Radians. (default is 0.8)
  25711. */
  25712. fov: number;
  25713. /**
  25714. * Define the minimum distance the camera can see from.
  25715. * This is important to note that the depth buffer are not infinite and the closer it starts
  25716. * the more your scene might encounter depth fighting issue.
  25717. */
  25718. minZ: number;
  25719. /**
  25720. * Define the maximum distance the camera can see to.
  25721. * This is important to note that the depth buffer are not infinite and the further it end
  25722. * the more your scene might encounter depth fighting issue.
  25723. */
  25724. maxZ: number;
  25725. /**
  25726. * Define the default inertia of the camera.
  25727. * This helps giving a smooth feeling to the camera movement.
  25728. */
  25729. inertia: number;
  25730. /**
  25731. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25732. */
  25733. mode: number;
  25734. /**
  25735. * Define whether the camera is intermediate.
  25736. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25737. */
  25738. isIntermediate: boolean;
  25739. /**
  25740. * Define the viewport of the camera.
  25741. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25742. */
  25743. viewport: Viewport;
  25744. /**
  25745. * Restricts the camera to viewing objects with the same layerMask.
  25746. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25747. */
  25748. layerMask: number;
  25749. /**
  25750. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25751. */
  25752. fovMode: number;
  25753. /**
  25754. * Rig mode of the camera.
  25755. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25756. * This is normally controlled byt the camera themselves as internal use.
  25757. */
  25758. cameraRigMode: number;
  25759. /**
  25760. * Defines the distance between both "eyes" in case of a RIG
  25761. */
  25762. interaxialDistance: number;
  25763. /**
  25764. * Defines if stereoscopic rendering is done side by side or over under.
  25765. */
  25766. isStereoscopicSideBySide: boolean;
  25767. /**
  25768. * 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
  25769. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25770. * else in the scene. (Eg. security camera)
  25771. *
  25772. * 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)
  25773. */
  25774. customRenderTargets: RenderTargetTexture[];
  25775. /**
  25776. * When set, the camera will render to this render target instead of the default canvas
  25777. *
  25778. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25779. */
  25780. outputRenderTarget: Nullable<RenderTargetTexture>;
  25781. /**
  25782. * Observable triggered when the camera view matrix has changed.
  25783. */
  25784. onViewMatrixChangedObservable: Observable<Camera>;
  25785. /**
  25786. * Observable triggered when the camera Projection matrix has changed.
  25787. */
  25788. onProjectionMatrixChangedObservable: Observable<Camera>;
  25789. /**
  25790. * Observable triggered when the inputs have been processed.
  25791. */
  25792. onAfterCheckInputsObservable: Observable<Camera>;
  25793. /**
  25794. * Observable triggered when reset has been called and applied to the camera.
  25795. */
  25796. onRestoreStateObservable: Observable<Camera>;
  25797. /**
  25798. * Is this camera a part of a rig system?
  25799. */
  25800. isRigCamera: boolean;
  25801. /**
  25802. * If isRigCamera set to true this will be set with the parent camera.
  25803. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25804. */
  25805. rigParent?: Camera;
  25806. /** @hidden */
  25807. _cameraRigParams: any;
  25808. /** @hidden */
  25809. _rigCameras: Camera[];
  25810. /** @hidden */
  25811. _rigPostProcess: Nullable<PostProcess>;
  25812. protected _webvrViewMatrix: Matrix;
  25813. /** @hidden */
  25814. _skipRendering: boolean;
  25815. /** @hidden */
  25816. _projectionMatrix: Matrix;
  25817. /** @hidden */
  25818. _postProcesses: Nullable<PostProcess>[];
  25819. /** @hidden */
  25820. _activeMeshes: SmartArray<AbstractMesh>;
  25821. protected _globalPosition: Vector3;
  25822. /** @hidden */
  25823. _computedViewMatrix: Matrix;
  25824. private _doNotComputeProjectionMatrix;
  25825. private _transformMatrix;
  25826. private _frustumPlanes;
  25827. private _refreshFrustumPlanes;
  25828. private _storedFov;
  25829. private _stateStored;
  25830. /**
  25831. * Instantiates a new camera object.
  25832. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25833. * @see http://doc.babylonjs.com/features/cameras
  25834. * @param name Defines the name of the camera in the scene
  25835. * @param position Defines the position of the camera
  25836. * @param scene Defines the scene the camera belongs too
  25837. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25838. */
  25839. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25840. /**
  25841. * Store current camera state (fov, position, etc..)
  25842. * @returns the camera
  25843. */
  25844. storeState(): Camera;
  25845. /**
  25846. * Restores the camera state values if it has been stored. You must call storeState() first
  25847. */
  25848. protected _restoreStateValues(): boolean;
  25849. /**
  25850. * Restored camera state. You must call storeState() first.
  25851. * @returns true if restored and false otherwise
  25852. */
  25853. restoreState(): boolean;
  25854. /**
  25855. * Gets the class name of the camera.
  25856. * @returns the class name
  25857. */
  25858. getClassName(): string;
  25859. /** @hidden */
  25860. readonly _isCamera: boolean;
  25861. /**
  25862. * Gets a string representation of the camera useful for debug purpose.
  25863. * @param fullDetails Defines that a more verboe level of logging is required
  25864. * @returns the string representation
  25865. */
  25866. toString(fullDetails?: boolean): string;
  25867. /**
  25868. * Gets the current world space position of the camera.
  25869. */
  25870. get globalPosition(): Vector3;
  25871. /**
  25872. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25873. * @returns the active meshe list
  25874. */
  25875. getActiveMeshes(): SmartArray<AbstractMesh>;
  25876. /**
  25877. * Check whether a mesh is part of the current active mesh list of the camera
  25878. * @param mesh Defines the mesh to check
  25879. * @returns true if active, false otherwise
  25880. */
  25881. isActiveMesh(mesh: Mesh): boolean;
  25882. /**
  25883. * Is this camera ready to be used/rendered
  25884. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25885. * @return true if the camera is ready
  25886. */
  25887. isReady(completeCheck?: boolean): boolean;
  25888. /** @hidden */
  25889. _initCache(): void;
  25890. /** @hidden */
  25891. _updateCache(ignoreParentClass?: boolean): void;
  25892. /** @hidden */
  25893. _isSynchronized(): boolean;
  25894. /** @hidden */
  25895. _isSynchronizedViewMatrix(): boolean;
  25896. /** @hidden */
  25897. _isSynchronizedProjectionMatrix(): boolean;
  25898. /**
  25899. * Attach the input controls to a specific dom element to get the input from.
  25900. * @param element Defines the element the controls should be listened from
  25901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25902. */
  25903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25904. /**
  25905. * Detach the current controls from the specified dom element.
  25906. * @param element Defines the element to stop listening the inputs from
  25907. */
  25908. detachControl(element: HTMLElement): void;
  25909. /**
  25910. * Update the camera state according to the different inputs gathered during the frame.
  25911. */
  25912. update(): void;
  25913. /** @hidden */
  25914. _checkInputs(): void;
  25915. /** @hidden */
  25916. get rigCameras(): Camera[];
  25917. /**
  25918. * Gets the post process used by the rig cameras
  25919. */
  25920. get rigPostProcess(): Nullable<PostProcess>;
  25921. /**
  25922. * Internal, gets the first post proces.
  25923. * @returns the first post process to be run on this camera.
  25924. */
  25925. _getFirstPostProcess(): Nullable<PostProcess>;
  25926. private _cascadePostProcessesToRigCams;
  25927. /**
  25928. * Attach a post process to the camera.
  25929. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25930. * @param postProcess The post process to attach to the camera
  25931. * @param insertAt The position of the post process in case several of them are in use in the scene
  25932. * @returns the position the post process has been inserted at
  25933. */
  25934. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25935. /**
  25936. * Detach a post process to the camera.
  25937. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25938. * @param postProcess The post process to detach from the camera
  25939. */
  25940. detachPostProcess(postProcess: PostProcess): void;
  25941. /**
  25942. * Gets the current world matrix of the camera
  25943. */
  25944. getWorldMatrix(): Matrix;
  25945. /** @hidden */
  25946. _getViewMatrix(): Matrix;
  25947. /**
  25948. * Gets the current view matrix of the camera.
  25949. * @param force forces the camera to recompute the matrix without looking at the cached state
  25950. * @returns the view matrix
  25951. */
  25952. getViewMatrix(force?: boolean): Matrix;
  25953. /**
  25954. * Freeze the projection matrix.
  25955. * It will prevent the cache check of the camera projection compute and can speed up perf
  25956. * if no parameter of the camera are meant to change
  25957. * @param projection Defines manually a projection if necessary
  25958. */
  25959. freezeProjectionMatrix(projection?: Matrix): void;
  25960. /**
  25961. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25962. */
  25963. unfreezeProjectionMatrix(): void;
  25964. /**
  25965. * Gets the current projection matrix of the camera.
  25966. * @param force forces the camera to recompute the matrix without looking at the cached state
  25967. * @returns the projection matrix
  25968. */
  25969. getProjectionMatrix(force?: boolean): Matrix;
  25970. /**
  25971. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25972. * @returns a Matrix
  25973. */
  25974. getTransformationMatrix(): Matrix;
  25975. private _updateFrustumPlanes;
  25976. /**
  25977. * Checks if a cullable object (mesh...) is in the camera frustum
  25978. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25979. * @param target The object to check
  25980. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25981. * @returns true if the object is in frustum otherwise false
  25982. */
  25983. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25984. /**
  25985. * Checks if a cullable object (mesh...) is in the camera frustum
  25986. * Unlike isInFrustum this cheks the full bounding box
  25987. * @param target The object to check
  25988. * @returns true if the object is in frustum otherwise false
  25989. */
  25990. isCompletelyInFrustum(target: ICullable): boolean;
  25991. /**
  25992. * Gets a ray in the forward direction from the camera.
  25993. * @param length Defines the length of the ray to create
  25994. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25995. * @param origin Defines the start point of the ray which defaults to the camera position
  25996. * @returns the forward ray
  25997. */
  25998. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25999. /**
  26000. * Releases resources associated with this node.
  26001. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26002. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26003. */
  26004. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26005. /** @hidden */
  26006. _isLeftCamera: boolean;
  26007. /**
  26008. * Gets the left camera of a rig setup in case of Rigged Camera
  26009. */
  26010. get isLeftCamera(): boolean;
  26011. /** @hidden */
  26012. _isRightCamera: boolean;
  26013. /**
  26014. * Gets the right camera of a rig setup in case of Rigged Camera
  26015. */
  26016. get isRightCamera(): boolean;
  26017. /**
  26018. * Gets the left camera of a rig setup in case of Rigged Camera
  26019. */
  26020. get leftCamera(): Nullable<FreeCamera>;
  26021. /**
  26022. * Gets the right camera of a rig setup in case of Rigged Camera
  26023. */
  26024. get rightCamera(): Nullable<FreeCamera>;
  26025. /**
  26026. * Gets the left camera target of a rig setup in case of Rigged Camera
  26027. * @returns the target position
  26028. */
  26029. getLeftTarget(): Nullable<Vector3>;
  26030. /**
  26031. * Gets the right camera target of a rig setup in case of Rigged Camera
  26032. * @returns the target position
  26033. */
  26034. getRightTarget(): Nullable<Vector3>;
  26035. /**
  26036. * @hidden
  26037. */
  26038. setCameraRigMode(mode: number, rigParams: any): void;
  26039. /** @hidden */
  26040. static _setStereoscopicRigMode(camera: Camera): void;
  26041. /** @hidden */
  26042. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26043. /** @hidden */
  26044. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26045. /** @hidden */
  26046. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26047. /** @hidden */
  26048. _getVRProjectionMatrix(): Matrix;
  26049. protected _updateCameraRotationMatrix(): void;
  26050. protected _updateWebVRCameraRotationMatrix(): void;
  26051. /**
  26052. * This function MUST be overwritten by the different WebVR cameras available.
  26053. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26054. * @hidden
  26055. */
  26056. _getWebVRProjectionMatrix(): Matrix;
  26057. /**
  26058. * This function MUST be overwritten by the different WebVR cameras available.
  26059. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26060. * @hidden
  26061. */
  26062. _getWebVRViewMatrix(): Matrix;
  26063. /** @hidden */
  26064. setCameraRigParameter(name: string, value: any): void;
  26065. /**
  26066. * needs to be overridden by children so sub has required properties to be copied
  26067. * @hidden
  26068. */
  26069. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26070. /**
  26071. * May need to be overridden by children
  26072. * @hidden
  26073. */
  26074. _updateRigCameras(): void;
  26075. /** @hidden */
  26076. _setupInputs(): void;
  26077. /**
  26078. * Serialiaze the camera setup to a json represention
  26079. * @returns the JSON representation
  26080. */
  26081. serialize(): any;
  26082. /**
  26083. * Clones the current camera.
  26084. * @param name The cloned camera name
  26085. * @returns the cloned camera
  26086. */
  26087. clone(name: string): Camera;
  26088. /**
  26089. * Gets the direction of the camera relative to a given local axis.
  26090. * @param localAxis Defines the reference axis to provide a relative direction.
  26091. * @return the direction
  26092. */
  26093. getDirection(localAxis: Vector3): Vector3;
  26094. /**
  26095. * Returns the current camera absolute rotation
  26096. */
  26097. get absoluteRotation(): Quaternion;
  26098. /**
  26099. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26100. * @param localAxis Defines the reference axis to provide a relative direction.
  26101. * @param result Defines the vector to store the result in
  26102. */
  26103. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26104. /**
  26105. * Gets a camera constructor for a given camera type
  26106. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26107. * @param name The name of the camera the result will be able to instantiate
  26108. * @param scene The scene the result will construct the camera in
  26109. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26110. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26111. * @returns a factory method to construc the camera
  26112. */
  26113. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26114. /**
  26115. * Compute the world matrix of the camera.
  26116. * @returns the camera world matrix
  26117. */
  26118. computeWorldMatrix(): Matrix;
  26119. /**
  26120. * Parse a JSON and creates the camera from the parsed information
  26121. * @param parsedCamera The JSON to parse
  26122. * @param scene The scene to instantiate the camera in
  26123. * @returns the newly constructed camera
  26124. */
  26125. static Parse(parsedCamera: any, scene: Scene): Camera;
  26126. }
  26127. }
  26128. declare module BABYLON {
  26129. /**
  26130. * Class containing static functions to help procedurally build meshes
  26131. */
  26132. export class DiscBuilder {
  26133. /**
  26134. * Creates a plane polygonal mesh. By default, this is a disc
  26135. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26136. * * 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
  26137. * * 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
  26138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26139. * * 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
  26140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26141. * @param name defines the name of the mesh
  26142. * @param options defines the options used to create the mesh
  26143. * @param scene defines the hosting scene
  26144. * @returns the plane polygonal mesh
  26145. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26146. */
  26147. static CreateDisc(name: string, options: {
  26148. radius?: number;
  26149. tessellation?: number;
  26150. arc?: number;
  26151. updatable?: boolean;
  26152. sideOrientation?: number;
  26153. frontUVs?: Vector4;
  26154. backUVs?: Vector4;
  26155. }, scene?: Nullable<Scene>): Mesh;
  26156. }
  26157. }
  26158. declare module BABYLON {
  26159. /**
  26160. * Options to be used when creating a FresnelParameters.
  26161. */
  26162. export type IFresnelParametersCreationOptions = {
  26163. /**
  26164. * Define the color used on edges (grazing angle)
  26165. */
  26166. leftColor?: Color3;
  26167. /**
  26168. * Define the color used on center
  26169. */
  26170. rightColor?: Color3;
  26171. /**
  26172. * Define bias applied to computed fresnel term
  26173. */
  26174. bias?: number;
  26175. /**
  26176. * Defined the power exponent applied to fresnel term
  26177. */
  26178. power?: number;
  26179. /**
  26180. * Define if the fresnel effect is enable or not.
  26181. */
  26182. isEnabled?: boolean;
  26183. };
  26184. /**
  26185. * Serialized format for FresnelParameters.
  26186. */
  26187. export type IFresnelParametersSerialized = {
  26188. /**
  26189. * Define the color used on edges (grazing angle) [as an array]
  26190. */
  26191. leftColor: number[];
  26192. /**
  26193. * Define the color used on center [as an array]
  26194. */
  26195. rightColor: number[];
  26196. /**
  26197. * Define bias applied to computed fresnel term
  26198. */
  26199. bias: number;
  26200. /**
  26201. * Defined the power exponent applied to fresnel term
  26202. */
  26203. power?: number;
  26204. /**
  26205. * Define if the fresnel effect is enable or not.
  26206. */
  26207. isEnabled: boolean;
  26208. };
  26209. /**
  26210. * This represents all the required information to add a fresnel effect on a material:
  26211. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26212. */
  26213. export class FresnelParameters {
  26214. private _isEnabled;
  26215. /**
  26216. * Define if the fresnel effect is enable or not.
  26217. */
  26218. get isEnabled(): boolean;
  26219. set isEnabled(value: boolean);
  26220. /**
  26221. * Define the color used on edges (grazing angle)
  26222. */
  26223. leftColor: Color3;
  26224. /**
  26225. * Define the color used on center
  26226. */
  26227. rightColor: Color3;
  26228. /**
  26229. * Define bias applied to computed fresnel term
  26230. */
  26231. bias: number;
  26232. /**
  26233. * Defined the power exponent applied to fresnel term
  26234. */
  26235. power: number;
  26236. /**
  26237. * Creates a new FresnelParameters object.
  26238. *
  26239. * @param options provide your own settings to optionally to override defaults
  26240. */
  26241. constructor(options?: IFresnelParametersCreationOptions);
  26242. /**
  26243. * Clones the current fresnel and its valuues
  26244. * @returns a clone fresnel configuration
  26245. */
  26246. clone(): FresnelParameters;
  26247. /**
  26248. * Determines equality between FresnelParameters objects
  26249. * @param otherFresnelParameters defines the second operand
  26250. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26251. */
  26252. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26253. /**
  26254. * Serializes the current fresnel parameters to a JSON representation.
  26255. * @return the JSON serialization
  26256. */
  26257. serialize(): IFresnelParametersSerialized;
  26258. /**
  26259. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26260. * @param parsedFresnelParameters Define the JSON representation
  26261. * @returns the parsed parameters
  26262. */
  26263. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26264. }
  26265. }
  26266. declare module BABYLON {
  26267. /**
  26268. * Base class of materials working in push mode in babylon JS
  26269. * @hidden
  26270. */
  26271. export class PushMaterial extends Material {
  26272. protected _activeEffect: Effect;
  26273. protected _normalMatrix: Matrix;
  26274. /**
  26275. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26276. * This means that the material can keep using a previous shader while a new one is being compiled.
  26277. * This is mostly used when shader parallel compilation is supported (true by default)
  26278. */
  26279. allowShaderHotSwapping: boolean;
  26280. constructor(name: string, scene: Scene);
  26281. getEffect(): Effect;
  26282. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26283. /**
  26284. * Binds the given world matrix to the active effect
  26285. *
  26286. * @param world the matrix to bind
  26287. */
  26288. bindOnlyWorldMatrix(world: Matrix): void;
  26289. /**
  26290. * Binds the given normal matrix to the active effect
  26291. *
  26292. * @param normalMatrix the matrix to bind
  26293. */
  26294. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26295. bind(world: Matrix, mesh?: Mesh): void;
  26296. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26297. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26298. }
  26299. }
  26300. declare module BABYLON {
  26301. /**
  26302. * This groups all the flags used to control the materials channel.
  26303. */
  26304. export class MaterialFlags {
  26305. private static _DiffuseTextureEnabled;
  26306. /**
  26307. * Are diffuse textures enabled in the application.
  26308. */
  26309. static get DiffuseTextureEnabled(): boolean;
  26310. static set DiffuseTextureEnabled(value: boolean);
  26311. private static _AmbientTextureEnabled;
  26312. /**
  26313. * Are ambient textures enabled in the application.
  26314. */
  26315. static get AmbientTextureEnabled(): boolean;
  26316. static set AmbientTextureEnabled(value: boolean);
  26317. private static _OpacityTextureEnabled;
  26318. /**
  26319. * Are opacity textures enabled in the application.
  26320. */
  26321. static get OpacityTextureEnabled(): boolean;
  26322. static set OpacityTextureEnabled(value: boolean);
  26323. private static _ReflectionTextureEnabled;
  26324. /**
  26325. * Are reflection textures enabled in the application.
  26326. */
  26327. static get ReflectionTextureEnabled(): boolean;
  26328. static set ReflectionTextureEnabled(value: boolean);
  26329. private static _EmissiveTextureEnabled;
  26330. /**
  26331. * Are emissive textures enabled in the application.
  26332. */
  26333. static get EmissiveTextureEnabled(): boolean;
  26334. static set EmissiveTextureEnabled(value: boolean);
  26335. private static _SpecularTextureEnabled;
  26336. /**
  26337. * Are specular textures enabled in the application.
  26338. */
  26339. static get SpecularTextureEnabled(): boolean;
  26340. static set SpecularTextureEnabled(value: boolean);
  26341. private static _BumpTextureEnabled;
  26342. /**
  26343. * Are bump textures enabled in the application.
  26344. */
  26345. static get BumpTextureEnabled(): boolean;
  26346. static set BumpTextureEnabled(value: boolean);
  26347. private static _LightmapTextureEnabled;
  26348. /**
  26349. * Are lightmap textures enabled in the application.
  26350. */
  26351. static get LightmapTextureEnabled(): boolean;
  26352. static set LightmapTextureEnabled(value: boolean);
  26353. private static _RefractionTextureEnabled;
  26354. /**
  26355. * Are refraction textures enabled in the application.
  26356. */
  26357. static get RefractionTextureEnabled(): boolean;
  26358. static set RefractionTextureEnabled(value: boolean);
  26359. private static _ColorGradingTextureEnabled;
  26360. /**
  26361. * Are color grading textures enabled in the application.
  26362. */
  26363. static get ColorGradingTextureEnabled(): boolean;
  26364. static set ColorGradingTextureEnabled(value: boolean);
  26365. private static _FresnelEnabled;
  26366. /**
  26367. * Are fresnels enabled in the application.
  26368. */
  26369. static get FresnelEnabled(): boolean;
  26370. static set FresnelEnabled(value: boolean);
  26371. private static _ClearCoatTextureEnabled;
  26372. /**
  26373. * Are clear coat textures enabled in the application.
  26374. */
  26375. static get ClearCoatTextureEnabled(): boolean;
  26376. static set ClearCoatTextureEnabled(value: boolean);
  26377. private static _ClearCoatBumpTextureEnabled;
  26378. /**
  26379. * Are clear coat bump textures enabled in the application.
  26380. */
  26381. static get ClearCoatBumpTextureEnabled(): boolean;
  26382. static set ClearCoatBumpTextureEnabled(value: boolean);
  26383. private static _ClearCoatTintTextureEnabled;
  26384. /**
  26385. * Are clear coat tint textures enabled in the application.
  26386. */
  26387. static get ClearCoatTintTextureEnabled(): boolean;
  26388. static set ClearCoatTintTextureEnabled(value: boolean);
  26389. private static _SheenTextureEnabled;
  26390. /**
  26391. * Are sheen textures enabled in the application.
  26392. */
  26393. static get SheenTextureEnabled(): boolean;
  26394. static set SheenTextureEnabled(value: boolean);
  26395. private static _AnisotropicTextureEnabled;
  26396. /**
  26397. * Are anisotropic textures enabled in the application.
  26398. */
  26399. static get AnisotropicTextureEnabled(): boolean;
  26400. static set AnisotropicTextureEnabled(value: boolean);
  26401. private static _ThicknessTextureEnabled;
  26402. /**
  26403. * Are thickness textures enabled in the application.
  26404. */
  26405. static get ThicknessTextureEnabled(): boolean;
  26406. static set ThicknessTextureEnabled(value: boolean);
  26407. }
  26408. }
  26409. declare module BABYLON {
  26410. /** @hidden */
  26411. export var defaultFragmentDeclaration: {
  26412. name: string;
  26413. shader: string;
  26414. };
  26415. }
  26416. declare module BABYLON {
  26417. /** @hidden */
  26418. export var defaultUboDeclaration: {
  26419. name: string;
  26420. shader: string;
  26421. };
  26422. }
  26423. declare module BABYLON {
  26424. /** @hidden */
  26425. export var lightFragmentDeclaration: {
  26426. name: string;
  26427. shader: string;
  26428. };
  26429. }
  26430. declare module BABYLON {
  26431. /** @hidden */
  26432. export var lightUboDeclaration: {
  26433. name: string;
  26434. shader: string;
  26435. };
  26436. }
  26437. declare module BABYLON {
  26438. /** @hidden */
  26439. export var lightsFragmentFunctions: {
  26440. name: string;
  26441. shader: string;
  26442. };
  26443. }
  26444. declare module BABYLON {
  26445. /** @hidden */
  26446. export var shadowsFragmentFunctions: {
  26447. name: string;
  26448. shader: string;
  26449. };
  26450. }
  26451. declare module BABYLON {
  26452. /** @hidden */
  26453. export var fresnelFunction: {
  26454. name: string;
  26455. shader: string;
  26456. };
  26457. }
  26458. declare module BABYLON {
  26459. /** @hidden */
  26460. export var reflectionFunction: {
  26461. name: string;
  26462. shader: string;
  26463. };
  26464. }
  26465. declare module BABYLON {
  26466. /** @hidden */
  26467. export var bumpFragmentFunctions: {
  26468. name: string;
  26469. shader: string;
  26470. };
  26471. }
  26472. declare module BABYLON {
  26473. /** @hidden */
  26474. export var logDepthDeclaration: {
  26475. name: string;
  26476. shader: string;
  26477. };
  26478. }
  26479. declare module BABYLON {
  26480. /** @hidden */
  26481. export var bumpFragment: {
  26482. name: string;
  26483. shader: string;
  26484. };
  26485. }
  26486. declare module BABYLON {
  26487. /** @hidden */
  26488. export var depthPrePass: {
  26489. name: string;
  26490. shader: string;
  26491. };
  26492. }
  26493. declare module BABYLON {
  26494. /** @hidden */
  26495. export var lightFragment: {
  26496. name: string;
  26497. shader: string;
  26498. };
  26499. }
  26500. declare module BABYLON {
  26501. /** @hidden */
  26502. export var logDepthFragment: {
  26503. name: string;
  26504. shader: string;
  26505. };
  26506. }
  26507. declare module BABYLON {
  26508. /** @hidden */
  26509. export var defaultPixelShader: {
  26510. name: string;
  26511. shader: string;
  26512. };
  26513. }
  26514. declare module BABYLON {
  26515. /** @hidden */
  26516. export var defaultVertexDeclaration: {
  26517. name: string;
  26518. shader: string;
  26519. };
  26520. }
  26521. declare module BABYLON {
  26522. /** @hidden */
  26523. export var bumpVertexDeclaration: {
  26524. name: string;
  26525. shader: string;
  26526. };
  26527. }
  26528. declare module BABYLON {
  26529. /** @hidden */
  26530. export var bumpVertex: {
  26531. name: string;
  26532. shader: string;
  26533. };
  26534. }
  26535. declare module BABYLON {
  26536. /** @hidden */
  26537. export var fogVertex: {
  26538. name: string;
  26539. shader: string;
  26540. };
  26541. }
  26542. declare module BABYLON {
  26543. /** @hidden */
  26544. export var shadowsVertex: {
  26545. name: string;
  26546. shader: string;
  26547. };
  26548. }
  26549. declare module BABYLON {
  26550. /** @hidden */
  26551. export var pointCloudVertex: {
  26552. name: string;
  26553. shader: string;
  26554. };
  26555. }
  26556. declare module BABYLON {
  26557. /** @hidden */
  26558. export var logDepthVertex: {
  26559. name: string;
  26560. shader: string;
  26561. };
  26562. }
  26563. declare module BABYLON {
  26564. /** @hidden */
  26565. export var defaultVertexShader: {
  26566. name: string;
  26567. shader: string;
  26568. };
  26569. }
  26570. declare module BABYLON {
  26571. /** @hidden */
  26572. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26573. MAINUV1: boolean;
  26574. MAINUV2: boolean;
  26575. DIFFUSE: boolean;
  26576. DIFFUSEDIRECTUV: number;
  26577. AMBIENT: boolean;
  26578. AMBIENTDIRECTUV: number;
  26579. OPACITY: boolean;
  26580. OPACITYDIRECTUV: number;
  26581. OPACITYRGB: boolean;
  26582. REFLECTION: boolean;
  26583. EMISSIVE: boolean;
  26584. EMISSIVEDIRECTUV: number;
  26585. SPECULAR: boolean;
  26586. SPECULARDIRECTUV: number;
  26587. BUMP: boolean;
  26588. BUMPDIRECTUV: number;
  26589. PARALLAX: boolean;
  26590. PARALLAXOCCLUSION: boolean;
  26591. SPECULAROVERALPHA: boolean;
  26592. CLIPPLANE: boolean;
  26593. CLIPPLANE2: boolean;
  26594. CLIPPLANE3: boolean;
  26595. CLIPPLANE4: boolean;
  26596. CLIPPLANE5: boolean;
  26597. CLIPPLANE6: boolean;
  26598. ALPHATEST: boolean;
  26599. DEPTHPREPASS: boolean;
  26600. ALPHAFROMDIFFUSE: boolean;
  26601. POINTSIZE: boolean;
  26602. FOG: boolean;
  26603. SPECULARTERM: boolean;
  26604. DIFFUSEFRESNEL: boolean;
  26605. OPACITYFRESNEL: boolean;
  26606. REFLECTIONFRESNEL: boolean;
  26607. REFRACTIONFRESNEL: boolean;
  26608. EMISSIVEFRESNEL: boolean;
  26609. FRESNEL: boolean;
  26610. NORMAL: boolean;
  26611. UV1: boolean;
  26612. UV2: boolean;
  26613. VERTEXCOLOR: boolean;
  26614. VERTEXALPHA: boolean;
  26615. NUM_BONE_INFLUENCERS: number;
  26616. BonesPerMesh: number;
  26617. BONETEXTURE: boolean;
  26618. INSTANCES: boolean;
  26619. GLOSSINESS: boolean;
  26620. ROUGHNESS: boolean;
  26621. EMISSIVEASILLUMINATION: boolean;
  26622. LINKEMISSIVEWITHDIFFUSE: boolean;
  26623. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26624. LIGHTMAP: boolean;
  26625. LIGHTMAPDIRECTUV: number;
  26626. OBJECTSPACE_NORMALMAP: boolean;
  26627. USELIGHTMAPASSHADOWMAP: boolean;
  26628. REFLECTIONMAP_3D: boolean;
  26629. REFLECTIONMAP_SPHERICAL: boolean;
  26630. REFLECTIONMAP_PLANAR: boolean;
  26631. REFLECTIONMAP_CUBIC: boolean;
  26632. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26633. REFLECTIONMAP_PROJECTION: boolean;
  26634. REFLECTIONMAP_SKYBOX: boolean;
  26635. REFLECTIONMAP_EXPLICIT: boolean;
  26636. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26637. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26638. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26639. INVERTCUBICMAP: boolean;
  26640. LOGARITHMICDEPTH: boolean;
  26641. REFRACTION: boolean;
  26642. REFRACTIONMAP_3D: boolean;
  26643. REFLECTIONOVERALPHA: boolean;
  26644. TWOSIDEDLIGHTING: boolean;
  26645. SHADOWFLOAT: boolean;
  26646. MORPHTARGETS: boolean;
  26647. MORPHTARGETS_NORMAL: boolean;
  26648. MORPHTARGETS_TANGENT: boolean;
  26649. MORPHTARGETS_UV: boolean;
  26650. NUM_MORPH_INFLUENCERS: number;
  26651. NONUNIFORMSCALING: boolean;
  26652. PREMULTIPLYALPHA: boolean;
  26653. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26654. ALPHABLEND: boolean;
  26655. IMAGEPROCESSING: boolean;
  26656. VIGNETTE: boolean;
  26657. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26658. VIGNETTEBLENDMODEOPAQUE: boolean;
  26659. TONEMAPPING: boolean;
  26660. TONEMAPPING_ACES: boolean;
  26661. CONTRAST: boolean;
  26662. COLORCURVES: boolean;
  26663. COLORGRADING: boolean;
  26664. COLORGRADING3D: boolean;
  26665. SAMPLER3DGREENDEPTH: boolean;
  26666. SAMPLER3DBGRMAP: boolean;
  26667. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26668. MULTIVIEW: boolean;
  26669. /**
  26670. * If the reflection texture on this material is in linear color space
  26671. * @hidden
  26672. */
  26673. IS_REFLECTION_LINEAR: boolean;
  26674. /**
  26675. * If the refraction texture on this material is in linear color space
  26676. * @hidden
  26677. */
  26678. IS_REFRACTION_LINEAR: boolean;
  26679. EXPOSURE: boolean;
  26680. constructor();
  26681. setReflectionMode(modeToEnable: string): void;
  26682. }
  26683. /**
  26684. * This is the default material used in Babylon. It is the best trade off between quality
  26685. * and performances.
  26686. * @see http://doc.babylonjs.com/babylon101/materials
  26687. */
  26688. export class StandardMaterial extends PushMaterial {
  26689. private _diffuseTexture;
  26690. /**
  26691. * The basic texture of the material as viewed under a light.
  26692. */
  26693. diffuseTexture: Nullable<BaseTexture>;
  26694. private _ambientTexture;
  26695. /**
  26696. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26697. */
  26698. ambientTexture: Nullable<BaseTexture>;
  26699. private _opacityTexture;
  26700. /**
  26701. * Define the transparency of the material from a texture.
  26702. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26703. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26704. */
  26705. opacityTexture: Nullable<BaseTexture>;
  26706. private _reflectionTexture;
  26707. /**
  26708. * Define the texture used to display the reflection.
  26709. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26710. */
  26711. reflectionTexture: Nullable<BaseTexture>;
  26712. private _emissiveTexture;
  26713. /**
  26714. * Define texture of the material as if self lit.
  26715. * This will be mixed in the final result even in the absence of light.
  26716. */
  26717. emissiveTexture: Nullable<BaseTexture>;
  26718. private _specularTexture;
  26719. /**
  26720. * Define how the color and intensity of the highlight given by the light in the material.
  26721. */
  26722. specularTexture: Nullable<BaseTexture>;
  26723. private _bumpTexture;
  26724. /**
  26725. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26726. * 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.
  26727. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26728. */
  26729. bumpTexture: Nullable<BaseTexture>;
  26730. private _lightmapTexture;
  26731. /**
  26732. * Complex lighting can be computationally expensive to compute at runtime.
  26733. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26734. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26735. */
  26736. lightmapTexture: Nullable<BaseTexture>;
  26737. private _refractionTexture;
  26738. /**
  26739. * Define the texture used to display the refraction.
  26740. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26741. */
  26742. refractionTexture: Nullable<BaseTexture>;
  26743. /**
  26744. * The color of the material lit by the environmental background lighting.
  26745. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26746. */
  26747. ambientColor: Color3;
  26748. /**
  26749. * The basic color of the material as viewed under a light.
  26750. */
  26751. diffuseColor: Color3;
  26752. /**
  26753. * Define how the color and intensity of the highlight given by the light in the material.
  26754. */
  26755. specularColor: Color3;
  26756. /**
  26757. * Define the color of the material as if self lit.
  26758. * This will be mixed in the final result even in the absence of light.
  26759. */
  26760. emissiveColor: Color3;
  26761. /**
  26762. * Defines how sharp are the highlights in the material.
  26763. * The bigger the value the sharper giving a more glossy feeling to the result.
  26764. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26765. */
  26766. specularPower: number;
  26767. private _useAlphaFromDiffuseTexture;
  26768. /**
  26769. * Does the transparency come from the diffuse texture alpha channel.
  26770. */
  26771. useAlphaFromDiffuseTexture: boolean;
  26772. private _useEmissiveAsIllumination;
  26773. /**
  26774. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26775. */
  26776. useEmissiveAsIllumination: boolean;
  26777. private _linkEmissiveWithDiffuse;
  26778. /**
  26779. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26780. * the emissive level when the final color is close to one.
  26781. */
  26782. linkEmissiveWithDiffuse: boolean;
  26783. private _useSpecularOverAlpha;
  26784. /**
  26785. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26786. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26787. */
  26788. useSpecularOverAlpha: boolean;
  26789. private _useReflectionOverAlpha;
  26790. /**
  26791. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26792. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26793. */
  26794. useReflectionOverAlpha: boolean;
  26795. private _disableLighting;
  26796. /**
  26797. * Does lights from the scene impacts this material.
  26798. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26799. */
  26800. disableLighting: boolean;
  26801. private _useObjectSpaceNormalMap;
  26802. /**
  26803. * Allows using an object space normal map (instead of tangent space).
  26804. */
  26805. useObjectSpaceNormalMap: boolean;
  26806. private _useParallax;
  26807. /**
  26808. * Is parallax enabled or not.
  26809. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26810. */
  26811. useParallax: boolean;
  26812. private _useParallaxOcclusion;
  26813. /**
  26814. * Is parallax occlusion enabled or not.
  26815. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26816. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26817. */
  26818. useParallaxOcclusion: boolean;
  26819. /**
  26820. * 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.
  26821. */
  26822. parallaxScaleBias: number;
  26823. private _roughness;
  26824. /**
  26825. * Helps to define how blurry the reflections should appears in the material.
  26826. */
  26827. roughness: number;
  26828. /**
  26829. * In case of refraction, define the value of the index of refraction.
  26830. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26831. */
  26832. indexOfRefraction: number;
  26833. /**
  26834. * Invert the refraction texture alongside the y axis.
  26835. * It can be useful with procedural textures or probe for instance.
  26836. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26837. */
  26838. invertRefractionY: boolean;
  26839. /**
  26840. * Defines the alpha limits in alpha test mode.
  26841. */
  26842. alphaCutOff: number;
  26843. private _useLightmapAsShadowmap;
  26844. /**
  26845. * In case of light mapping, define whether the map contains light or shadow informations.
  26846. */
  26847. useLightmapAsShadowmap: boolean;
  26848. private _diffuseFresnelParameters;
  26849. /**
  26850. * Define the diffuse fresnel parameters of the material.
  26851. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26852. */
  26853. diffuseFresnelParameters: FresnelParameters;
  26854. private _opacityFresnelParameters;
  26855. /**
  26856. * Define the opacity fresnel parameters of the material.
  26857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26858. */
  26859. opacityFresnelParameters: FresnelParameters;
  26860. private _reflectionFresnelParameters;
  26861. /**
  26862. * Define the reflection fresnel parameters of the material.
  26863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26864. */
  26865. reflectionFresnelParameters: FresnelParameters;
  26866. private _refractionFresnelParameters;
  26867. /**
  26868. * Define the refraction fresnel parameters of the material.
  26869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26870. */
  26871. refractionFresnelParameters: FresnelParameters;
  26872. private _emissiveFresnelParameters;
  26873. /**
  26874. * Define the emissive fresnel parameters of the material.
  26875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26876. */
  26877. emissiveFresnelParameters: FresnelParameters;
  26878. private _useReflectionFresnelFromSpecular;
  26879. /**
  26880. * If true automatically deducts the fresnels values from the material specularity.
  26881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26882. */
  26883. useReflectionFresnelFromSpecular: boolean;
  26884. private _useGlossinessFromSpecularMapAlpha;
  26885. /**
  26886. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26887. */
  26888. useGlossinessFromSpecularMapAlpha: boolean;
  26889. private _maxSimultaneousLights;
  26890. /**
  26891. * Defines the maximum number of lights that can be used in the material
  26892. */
  26893. maxSimultaneousLights: number;
  26894. private _invertNormalMapX;
  26895. /**
  26896. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26897. */
  26898. invertNormalMapX: boolean;
  26899. private _invertNormalMapY;
  26900. /**
  26901. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26902. */
  26903. invertNormalMapY: boolean;
  26904. private _twoSidedLighting;
  26905. /**
  26906. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26907. */
  26908. twoSidedLighting: boolean;
  26909. /**
  26910. * Default configuration related to image processing available in the standard Material.
  26911. */
  26912. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26913. /**
  26914. * Gets the image processing configuration used either in this material.
  26915. */
  26916. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26917. /**
  26918. * Sets the Default image processing configuration used either in the this material.
  26919. *
  26920. * If sets to null, the scene one is in use.
  26921. */
  26922. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26923. /**
  26924. * Keep track of the image processing observer to allow dispose and replace.
  26925. */
  26926. private _imageProcessingObserver;
  26927. /**
  26928. * Attaches a new image processing configuration to the Standard Material.
  26929. * @param configuration
  26930. */
  26931. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26932. /**
  26933. * Gets wether the color curves effect is enabled.
  26934. */
  26935. get cameraColorCurvesEnabled(): boolean;
  26936. /**
  26937. * Sets wether the color curves effect is enabled.
  26938. */
  26939. set cameraColorCurvesEnabled(value: boolean);
  26940. /**
  26941. * Gets wether the color grading effect is enabled.
  26942. */
  26943. get cameraColorGradingEnabled(): boolean;
  26944. /**
  26945. * Gets wether the color grading effect is enabled.
  26946. */
  26947. set cameraColorGradingEnabled(value: boolean);
  26948. /**
  26949. * Gets wether tonemapping is enabled or not.
  26950. */
  26951. get cameraToneMappingEnabled(): boolean;
  26952. /**
  26953. * Sets wether tonemapping is enabled or not
  26954. */
  26955. set cameraToneMappingEnabled(value: boolean);
  26956. /**
  26957. * The camera exposure used on this material.
  26958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26959. * This corresponds to a photographic exposure.
  26960. */
  26961. get cameraExposure(): number;
  26962. /**
  26963. * The camera exposure used on this material.
  26964. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26965. * This corresponds to a photographic exposure.
  26966. */
  26967. set cameraExposure(value: number);
  26968. /**
  26969. * Gets The camera contrast used on this material.
  26970. */
  26971. get cameraContrast(): number;
  26972. /**
  26973. * Sets The camera contrast used on this material.
  26974. */
  26975. set cameraContrast(value: number);
  26976. /**
  26977. * Gets the Color Grading 2D Lookup Texture.
  26978. */
  26979. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26980. /**
  26981. * Sets the Color Grading 2D Lookup Texture.
  26982. */
  26983. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26984. /**
  26985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26987. * 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;
  26988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26989. */
  26990. get cameraColorCurves(): Nullable<ColorCurves>;
  26991. /**
  26992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26994. * 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;
  26995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26996. */
  26997. set cameraColorCurves(value: Nullable<ColorCurves>);
  26998. /**
  26999. * Custom callback helping to override the default shader used in the material.
  27000. */
  27001. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27002. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27003. protected _worldViewProjectionMatrix: Matrix;
  27004. protected _globalAmbientColor: Color3;
  27005. protected _useLogarithmicDepth: boolean;
  27006. protected _rebuildInParallel: boolean;
  27007. /**
  27008. * Instantiates a new standard material.
  27009. * This is the default material used in Babylon. It is the best trade off between quality
  27010. * and performances.
  27011. * @see http://doc.babylonjs.com/babylon101/materials
  27012. * @param name Define the name of the material in the scene
  27013. * @param scene Define the scene the material belong to
  27014. */
  27015. constructor(name: string, scene: Scene);
  27016. /**
  27017. * Gets a boolean indicating that current material needs to register RTT
  27018. */
  27019. get hasRenderTargetTextures(): boolean;
  27020. /**
  27021. * Gets the current class name of the material e.g. "StandardMaterial"
  27022. * Mainly use in serialization.
  27023. * @returns the class name
  27024. */
  27025. getClassName(): string;
  27026. /**
  27027. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27028. * You can try switching to logarithmic depth.
  27029. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27030. */
  27031. get useLogarithmicDepth(): boolean;
  27032. set useLogarithmicDepth(value: boolean);
  27033. /**
  27034. * Specifies if the material will require alpha blending
  27035. * @returns a boolean specifying if alpha blending is needed
  27036. */
  27037. needAlphaBlending(): boolean;
  27038. /**
  27039. * Specifies if this material should be rendered in alpha test mode
  27040. * @returns a boolean specifying if an alpha test is needed.
  27041. */
  27042. needAlphaTesting(): boolean;
  27043. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27044. /**
  27045. * Get the texture used for alpha test purpose.
  27046. * @returns the diffuse texture in case of the standard material.
  27047. */
  27048. getAlphaTestTexture(): Nullable<BaseTexture>;
  27049. /**
  27050. * Get if the submesh is ready to be used and all its information available.
  27051. * Child classes can use it to update shaders
  27052. * @param mesh defines the mesh to check
  27053. * @param subMesh defines which submesh to check
  27054. * @param useInstances specifies that instances should be used
  27055. * @returns a boolean indicating that the submesh is ready or not
  27056. */
  27057. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27058. /**
  27059. * Builds the material UBO layouts.
  27060. * Used internally during the effect preparation.
  27061. */
  27062. buildUniformLayout(): void;
  27063. /**
  27064. * Unbinds the material from the mesh
  27065. */
  27066. unbind(): void;
  27067. /**
  27068. * Binds the submesh to this material by preparing the effect and shader to draw
  27069. * @param world defines the world transformation matrix
  27070. * @param mesh defines the mesh containing the submesh
  27071. * @param subMesh defines the submesh to bind the material to
  27072. */
  27073. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27074. /**
  27075. * Get the list of animatables in the material.
  27076. * @returns the list of animatables object used in the material
  27077. */
  27078. getAnimatables(): IAnimatable[];
  27079. /**
  27080. * Gets the active textures from the material
  27081. * @returns an array of textures
  27082. */
  27083. getActiveTextures(): BaseTexture[];
  27084. /**
  27085. * Specifies if the material uses a texture
  27086. * @param texture defines the texture to check against the material
  27087. * @returns a boolean specifying if the material uses the texture
  27088. */
  27089. hasTexture(texture: BaseTexture): boolean;
  27090. /**
  27091. * Disposes the material
  27092. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27093. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27094. */
  27095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27096. /**
  27097. * Makes a duplicate of the material, and gives it a new name
  27098. * @param name defines the new name for the duplicated material
  27099. * @returns the cloned material
  27100. */
  27101. clone(name: string): StandardMaterial;
  27102. /**
  27103. * Serializes this material in a JSON representation
  27104. * @returns the serialized material object
  27105. */
  27106. serialize(): any;
  27107. /**
  27108. * Creates a standard material from parsed material data
  27109. * @param source defines the JSON representation of the material
  27110. * @param scene defines the hosting scene
  27111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27112. * @returns a new standard material
  27113. */
  27114. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27115. /**
  27116. * Are diffuse textures enabled in the application.
  27117. */
  27118. static get DiffuseTextureEnabled(): boolean;
  27119. static set DiffuseTextureEnabled(value: boolean);
  27120. /**
  27121. * Are ambient textures enabled in the application.
  27122. */
  27123. static get AmbientTextureEnabled(): boolean;
  27124. static set AmbientTextureEnabled(value: boolean);
  27125. /**
  27126. * Are opacity textures enabled in the application.
  27127. */
  27128. static get OpacityTextureEnabled(): boolean;
  27129. static set OpacityTextureEnabled(value: boolean);
  27130. /**
  27131. * Are reflection textures enabled in the application.
  27132. */
  27133. static get ReflectionTextureEnabled(): boolean;
  27134. static set ReflectionTextureEnabled(value: boolean);
  27135. /**
  27136. * Are emissive textures enabled in the application.
  27137. */
  27138. static get EmissiveTextureEnabled(): boolean;
  27139. static set EmissiveTextureEnabled(value: boolean);
  27140. /**
  27141. * Are specular textures enabled in the application.
  27142. */
  27143. static get SpecularTextureEnabled(): boolean;
  27144. static set SpecularTextureEnabled(value: boolean);
  27145. /**
  27146. * Are bump textures enabled in the application.
  27147. */
  27148. static get BumpTextureEnabled(): boolean;
  27149. static set BumpTextureEnabled(value: boolean);
  27150. /**
  27151. * Are lightmap textures enabled in the application.
  27152. */
  27153. static get LightmapTextureEnabled(): boolean;
  27154. static set LightmapTextureEnabled(value: boolean);
  27155. /**
  27156. * Are refraction textures enabled in the application.
  27157. */
  27158. static get RefractionTextureEnabled(): boolean;
  27159. static set RefractionTextureEnabled(value: boolean);
  27160. /**
  27161. * Are color grading textures enabled in the application.
  27162. */
  27163. static get ColorGradingTextureEnabled(): boolean;
  27164. static set ColorGradingTextureEnabled(value: boolean);
  27165. /**
  27166. * Are fresnels enabled in the application.
  27167. */
  27168. static get FresnelEnabled(): boolean;
  27169. static set FresnelEnabled(value: boolean);
  27170. }
  27171. }
  27172. declare module BABYLON {
  27173. /**
  27174. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27175. *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.
  27176. * The SPS is also a particle system. It provides some methods to manage the particles.
  27177. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27178. *
  27179. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27180. */
  27181. export class SolidParticleSystem implements IDisposable {
  27182. /**
  27183. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27184. * Example : var p = SPS.particles[i];
  27185. */
  27186. particles: SolidParticle[];
  27187. /**
  27188. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27189. */
  27190. nbParticles: number;
  27191. /**
  27192. * If the particles must ever face the camera (default false). Useful for planar particles.
  27193. */
  27194. billboard: boolean;
  27195. /**
  27196. * Recompute normals when adding a shape
  27197. */
  27198. recomputeNormals: boolean;
  27199. /**
  27200. * This a counter ofr your own usage. It's not set by any SPS functions.
  27201. */
  27202. counter: number;
  27203. /**
  27204. * The SPS name. This name is also given to the underlying mesh.
  27205. */
  27206. name: string;
  27207. /**
  27208. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27209. */
  27210. mesh: Mesh;
  27211. /**
  27212. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27213. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27214. */
  27215. vars: any;
  27216. /**
  27217. * This array is populated when the SPS is set as 'pickable'.
  27218. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27219. * Each element of this array is an object `{idx: int, faceId: int}`.
  27220. * `idx` is the picked particle index in the `SPS.particles` array
  27221. * `faceId` is the picked face index counted within this particle.
  27222. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27223. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27224. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27225. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27226. */
  27227. pickedParticles: {
  27228. idx: number;
  27229. faceId: number;
  27230. }[];
  27231. /**
  27232. * This array is populated when the SPS is set as 'pickable'
  27233. * Each key of this array is a submesh index.
  27234. * Each element of this array is a second array defined like this :
  27235. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27236. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27237. * `idx` is the picked particle index in the `SPS.particles` array
  27238. * `faceId` is the picked face index counted within this particle.
  27239. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27240. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27241. */
  27242. pickedBySubMesh: {
  27243. idx: number;
  27244. faceId: number;
  27245. }[][];
  27246. /**
  27247. * This array is populated when `enableDepthSort` is set to true.
  27248. * Each element of this array is an instance of the class DepthSortedParticle.
  27249. */
  27250. depthSortedParticles: DepthSortedParticle[];
  27251. /**
  27252. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27253. * @hidden
  27254. */
  27255. _bSphereOnly: boolean;
  27256. /**
  27257. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27258. * @hidden
  27259. */
  27260. _bSphereRadiusFactor: number;
  27261. private _scene;
  27262. private _positions;
  27263. private _indices;
  27264. private _normals;
  27265. private _colors;
  27266. private _uvs;
  27267. private _indices32;
  27268. private _positions32;
  27269. private _normals32;
  27270. private _fixedNormal32;
  27271. private _colors32;
  27272. private _uvs32;
  27273. private _index;
  27274. private _updatable;
  27275. private _pickable;
  27276. private _isVisibilityBoxLocked;
  27277. private _alwaysVisible;
  27278. private _depthSort;
  27279. private _expandable;
  27280. private _shapeCounter;
  27281. private _copy;
  27282. private _color;
  27283. private _computeParticleColor;
  27284. private _computeParticleTexture;
  27285. private _computeParticleRotation;
  27286. private _computeParticleVertex;
  27287. private _computeBoundingBox;
  27288. private _depthSortParticles;
  27289. private _camera;
  27290. private _mustUnrotateFixedNormals;
  27291. private _particlesIntersect;
  27292. private _needs32Bits;
  27293. private _isNotBuilt;
  27294. private _lastParticleId;
  27295. private _idxOfId;
  27296. private _multimaterialEnabled;
  27297. private _useModelMaterial;
  27298. private _indicesByMaterial;
  27299. private _materialIndexes;
  27300. private _depthSortFunction;
  27301. private _materialSortFunction;
  27302. private _materials;
  27303. private _multimaterial;
  27304. private _materialIndexesById;
  27305. private _defaultMaterial;
  27306. private _autoUpdateSubMeshes;
  27307. /**
  27308. * Creates a SPS (Solid Particle System) object.
  27309. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27310. * @param scene (Scene) is the scene in which the SPS is added.
  27311. * @param options defines the options of the sps e.g.
  27312. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27313. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27314. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27315. * * 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.
  27316. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27317. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27318. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27319. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27320. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27321. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27322. */
  27323. constructor(name: string, scene: Scene, options?: {
  27324. updatable?: boolean;
  27325. isPickable?: boolean;
  27326. enableDepthSort?: boolean;
  27327. particleIntersection?: boolean;
  27328. boundingSphereOnly?: boolean;
  27329. bSphereRadiusFactor?: number;
  27330. expandable?: boolean;
  27331. useModelMaterial?: boolean;
  27332. enableMultiMaterial?: boolean;
  27333. });
  27334. /**
  27335. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27336. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27337. * @returns the created mesh
  27338. */
  27339. buildMesh(): Mesh;
  27340. /**
  27341. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27342. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27343. * Thus the particles generated from `digest()` have their property `position` set yet.
  27344. * @param mesh ( Mesh ) is the mesh to be digested
  27345. * @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
  27346. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27347. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27348. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27349. * @returns the current SPS
  27350. */
  27351. digest(mesh: Mesh, options?: {
  27352. facetNb?: number;
  27353. number?: number;
  27354. delta?: number;
  27355. storage?: [];
  27356. }): SolidParticleSystem;
  27357. /**
  27358. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27359. * @hidden
  27360. */
  27361. private _unrotateFixedNormals;
  27362. /**
  27363. * Resets the temporary working copy particle
  27364. * @hidden
  27365. */
  27366. private _resetCopy;
  27367. /**
  27368. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27369. * @param p the current index in the positions array to be updated
  27370. * @param ind the current index in the indices array
  27371. * @param shape a Vector3 array, the shape geometry
  27372. * @param positions the positions array to be updated
  27373. * @param meshInd the shape indices array
  27374. * @param indices the indices array to be updated
  27375. * @param meshUV the shape uv array
  27376. * @param uvs the uv array to be updated
  27377. * @param meshCol the shape color array
  27378. * @param colors the color array to be updated
  27379. * @param meshNor the shape normals array
  27380. * @param normals the normals array to be updated
  27381. * @param idx the particle index
  27382. * @param idxInShape the particle index in its shape
  27383. * @param options the addShape() method passed options
  27384. * @model the particle model
  27385. * @hidden
  27386. */
  27387. private _meshBuilder;
  27388. /**
  27389. * Returns a shape Vector3 array from positions float array
  27390. * @param positions float array
  27391. * @returns a vector3 array
  27392. * @hidden
  27393. */
  27394. private _posToShape;
  27395. /**
  27396. * Returns a shapeUV array from a float uvs (array deep copy)
  27397. * @param uvs as a float array
  27398. * @returns a shapeUV array
  27399. * @hidden
  27400. */
  27401. private _uvsToShapeUV;
  27402. /**
  27403. * Adds a new particle object in the particles array
  27404. * @param idx particle index in particles array
  27405. * @param id particle id
  27406. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27407. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27408. * @param model particle ModelShape object
  27409. * @param shapeId model shape identifier
  27410. * @param idxInShape index of the particle in the current model
  27411. * @param bInfo model bounding info object
  27412. * @param storage target storage array, if any
  27413. * @hidden
  27414. */
  27415. private _addParticle;
  27416. /**
  27417. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27418. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27419. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27420. * @param nb (positive integer) the number of particles to be created from this model
  27421. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27422. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27423. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27424. * @returns the number of shapes in the system
  27425. */
  27426. addShape(mesh: Mesh, nb: number, options?: {
  27427. positionFunction?: any;
  27428. vertexFunction?: any;
  27429. storage?: [];
  27430. }): number;
  27431. /**
  27432. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27433. * @hidden
  27434. */
  27435. private _rebuildParticle;
  27436. /**
  27437. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27438. * @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.
  27439. * @returns the SPS.
  27440. */
  27441. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27442. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27443. * Returns an array with the removed particles.
  27444. * 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.
  27445. * The SPS can't be empty so at least one particle needs to remain in place.
  27446. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27447. * @param start index of the first particle to remove
  27448. * @param end index of the last particle to remove (included)
  27449. * @returns an array populated with the removed particles
  27450. */
  27451. removeParticles(start: number, end: number): SolidParticle[];
  27452. /**
  27453. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27454. * @param solidParticleArray an array populated with Solid Particles objects
  27455. * @returns the SPS
  27456. */
  27457. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27458. /**
  27459. * Creates a new particle and modifies the SPS mesh geometry :
  27460. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27461. * - calls _addParticle() to populate the particle array
  27462. * factorized code from addShape() and insertParticlesFromArray()
  27463. * @param idx particle index in the particles array
  27464. * @param i particle index in its shape
  27465. * @param modelShape particle ModelShape object
  27466. * @param shape shape vertex array
  27467. * @param meshInd shape indices array
  27468. * @param meshUV shape uv array
  27469. * @param meshCol shape color array
  27470. * @param meshNor shape normals array
  27471. * @param bbInfo shape bounding info
  27472. * @param storage target particle storage
  27473. * @options addShape() passed options
  27474. * @hidden
  27475. */
  27476. private _insertNewParticle;
  27477. /**
  27478. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27479. * This method calls `updateParticle()` for each particle of the SPS.
  27480. * For an animated SPS, it is usually called within the render loop.
  27481. * 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.
  27482. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27483. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27484. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27485. * @returns the SPS.
  27486. */
  27487. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27488. /**
  27489. * Disposes the SPS.
  27490. */
  27491. dispose(): void;
  27492. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27493. * idx is the particle index in the SPS
  27494. * faceId is the picked face index counted within this particle.
  27495. * Returns null if the pickInfo can't identify a picked particle.
  27496. * @param pickingInfo (PickingInfo object)
  27497. * @returns {idx: number, faceId: number} or null
  27498. */
  27499. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27500. idx: number;
  27501. faceId: number;
  27502. }>;
  27503. /**
  27504. * Returns a SolidParticle object from its identifier : particle.id
  27505. * @param id (integer) the particle Id
  27506. * @returns the searched particle or null if not found in the SPS.
  27507. */
  27508. getParticleById(id: number): Nullable<SolidParticle>;
  27509. /**
  27510. * Returns a new array populated with the particles having the passed shapeId.
  27511. * @param shapeId (integer) the shape identifier
  27512. * @returns a new solid particle array
  27513. */
  27514. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27515. /**
  27516. * Populates the passed array "ref" with the particles having the passed shapeId.
  27517. * @param shapeId the shape identifier
  27518. * @returns the SPS
  27519. * @param ref
  27520. */
  27521. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27522. /**
  27523. * Computes the required SubMeshes according the materials assigned to the particles.
  27524. * @returns the solid particle system.
  27525. * Does nothing if called before the SPS mesh is built.
  27526. */
  27527. computeSubMeshes(): SolidParticleSystem;
  27528. /**
  27529. * Sorts the solid particles by material when MultiMaterial is enabled.
  27530. * Updates the indices32 array.
  27531. * Updates the indicesByMaterial array.
  27532. * Updates the mesh indices array.
  27533. * @returns the SPS
  27534. * @hidden
  27535. */
  27536. private _sortParticlesByMaterial;
  27537. /**
  27538. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27539. * @hidden
  27540. */
  27541. private _setMaterialIndexesById;
  27542. /**
  27543. * Returns an array with unique values of Materials from the passed array
  27544. * @param array the material array to be checked and filtered
  27545. * @hidden
  27546. */
  27547. private _filterUniqueMaterialId;
  27548. /**
  27549. * Sets a new Standard Material as _defaultMaterial if not already set.
  27550. * @hidden
  27551. */
  27552. private _setDefaultMaterial;
  27553. /**
  27554. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27556. * @returns the SPS.
  27557. */
  27558. refreshVisibleSize(): SolidParticleSystem;
  27559. /**
  27560. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27561. * @param size the size (float) of the visibility box
  27562. * note : this doesn't lock the SPS mesh bounding box.
  27563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27564. */
  27565. setVisibilityBox(size: number): void;
  27566. /**
  27567. * Gets whether the SPS as always visible or not
  27568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27569. */
  27570. get isAlwaysVisible(): boolean;
  27571. /**
  27572. * Sets the SPS as always visible or not
  27573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27574. */
  27575. set isAlwaysVisible(val: boolean);
  27576. /**
  27577. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27579. */
  27580. set isVisibilityBoxLocked(val: boolean);
  27581. /**
  27582. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27584. */
  27585. get isVisibilityBoxLocked(): boolean;
  27586. /**
  27587. * Tells to `setParticles()` to compute the particle rotations or not.
  27588. * Default value : true. The SPS is faster when it's set to false.
  27589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27590. */
  27591. set computeParticleRotation(val: boolean);
  27592. /**
  27593. * Tells to `setParticles()` to compute the particle colors or not.
  27594. * Default value : true. The SPS is faster when it's set to false.
  27595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27596. */
  27597. set computeParticleColor(val: boolean);
  27598. set computeParticleTexture(val: boolean);
  27599. /**
  27600. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27601. * Default value : false. The SPS is faster when it's set to false.
  27602. * Note : the particle custom vertex positions aren't stored values.
  27603. */
  27604. set computeParticleVertex(val: boolean);
  27605. /**
  27606. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27607. */
  27608. set computeBoundingBox(val: boolean);
  27609. /**
  27610. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27611. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27612. * Default : `true`
  27613. */
  27614. set depthSortParticles(val: boolean);
  27615. /**
  27616. * Gets if `setParticles()` computes the particle rotations or not.
  27617. * Default value : true. The SPS is faster when it's set to false.
  27618. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27619. */
  27620. get computeParticleRotation(): boolean;
  27621. /**
  27622. * Gets if `setParticles()` computes the particle colors or not.
  27623. * Default value : true. The SPS is faster when it's set to false.
  27624. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27625. */
  27626. get computeParticleColor(): boolean;
  27627. /**
  27628. * Gets if `setParticles()` computes the particle textures or not.
  27629. * Default value : true. The SPS is faster when it's set to false.
  27630. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27631. */
  27632. get computeParticleTexture(): boolean;
  27633. /**
  27634. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27635. * Default value : false. The SPS is faster when it's set to false.
  27636. * Note : the particle custom vertex positions aren't stored values.
  27637. */
  27638. get computeParticleVertex(): boolean;
  27639. /**
  27640. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27641. */
  27642. get computeBoundingBox(): boolean;
  27643. /**
  27644. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27646. * Default : `true`
  27647. */
  27648. get depthSortParticles(): boolean;
  27649. /**
  27650. * Gets if the SPS is created as expandable at construction time.
  27651. * Default : `false`
  27652. */
  27653. get expandable(): boolean;
  27654. /**
  27655. * Gets if the SPS supports the Multi Materials
  27656. */
  27657. get multimaterialEnabled(): boolean;
  27658. /**
  27659. * Gets if the SPS uses the model materials for its own multimaterial.
  27660. */
  27661. get useModelMaterial(): boolean;
  27662. /**
  27663. * The SPS used material array.
  27664. */
  27665. get materials(): Material[];
  27666. /**
  27667. * Sets the SPS MultiMaterial from the passed materials.
  27668. * Note : the passed array is internally copied and not used then by reference.
  27669. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27670. */
  27671. setMultiMaterial(materials: Material[]): void;
  27672. /**
  27673. * The SPS computed multimaterial object
  27674. */
  27675. get multimaterial(): MultiMaterial;
  27676. set multimaterial(mm: MultiMaterial);
  27677. /**
  27678. * If the subMeshes must be updated on the next call to setParticles()
  27679. */
  27680. get autoUpdateSubMeshes(): boolean;
  27681. set autoUpdateSubMeshes(val: boolean);
  27682. /**
  27683. * This function does nothing. It may be overwritten to set all the particle first values.
  27684. * The SPS doesn't call this function, you may have to call it by your own.
  27685. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27686. */
  27687. initParticles(): void;
  27688. /**
  27689. * This function does nothing. It may be overwritten to recycle a particle.
  27690. * The SPS doesn't call this function, you may have to call it by your own.
  27691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27692. * @param particle The particle to recycle
  27693. * @returns the recycled particle
  27694. */
  27695. recycleParticle(particle: SolidParticle): SolidParticle;
  27696. /**
  27697. * Updates a particle : this function should be overwritten by the user.
  27698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27700. * @example : just set a particle position or velocity and recycle conditions
  27701. * @param particle The particle to update
  27702. * @returns the updated particle
  27703. */
  27704. updateParticle(particle: SolidParticle): SolidParticle;
  27705. /**
  27706. * Updates a vertex of a particle : it can be overwritten by the user.
  27707. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27708. * @param particle the current particle
  27709. * @param vertex the current index of the current particle
  27710. * @param pt the index of the current vertex in the particle shape
  27711. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27712. * @example : just set a vertex particle position
  27713. * @returns the updated vertex
  27714. */
  27715. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27716. /**
  27717. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27718. * This does nothing and may be overwritten by the user.
  27719. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27721. * @param update the boolean update value actually passed to setParticles()
  27722. */
  27723. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27724. /**
  27725. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27726. * This will be passed three parameters.
  27727. * This does nothing and may be overwritten by the user.
  27728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27730. * @param update the boolean update value actually passed to setParticles()
  27731. */
  27732. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27733. }
  27734. }
  27735. declare module BABYLON {
  27736. /**
  27737. * Represents one particle of a solid particle system.
  27738. */
  27739. export class SolidParticle {
  27740. /**
  27741. * particle global index
  27742. */
  27743. idx: number;
  27744. /**
  27745. * particle identifier
  27746. */
  27747. id: number;
  27748. /**
  27749. * The color of the particle
  27750. */
  27751. color: Nullable<Color4>;
  27752. /**
  27753. * The world space position of the particle.
  27754. */
  27755. position: Vector3;
  27756. /**
  27757. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27758. */
  27759. rotation: Vector3;
  27760. /**
  27761. * The world space rotation quaternion of the particle.
  27762. */
  27763. rotationQuaternion: Nullable<Quaternion>;
  27764. /**
  27765. * The scaling of the particle.
  27766. */
  27767. scaling: Vector3;
  27768. /**
  27769. * The uvs of the particle.
  27770. */
  27771. uvs: Vector4;
  27772. /**
  27773. * The current speed of the particle.
  27774. */
  27775. velocity: Vector3;
  27776. /**
  27777. * The pivot point in the particle local space.
  27778. */
  27779. pivot: Vector3;
  27780. /**
  27781. * Must the particle be translated from its pivot point in its local space ?
  27782. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27783. * Default : false
  27784. */
  27785. translateFromPivot: boolean;
  27786. /**
  27787. * Is the particle active or not ?
  27788. */
  27789. alive: boolean;
  27790. /**
  27791. * Is the particle visible or not ?
  27792. */
  27793. isVisible: boolean;
  27794. /**
  27795. * Index of this particle in the global "positions" array (Internal use)
  27796. * @hidden
  27797. */
  27798. _pos: number;
  27799. /**
  27800. * @hidden Index of this particle in the global "indices" array (Internal use)
  27801. */
  27802. _ind: number;
  27803. /**
  27804. * @hidden ModelShape of this particle (Internal use)
  27805. */
  27806. _model: ModelShape;
  27807. /**
  27808. * ModelShape id of this particle
  27809. */
  27810. shapeId: number;
  27811. /**
  27812. * Index of the particle in its shape id
  27813. */
  27814. idxInShape: number;
  27815. /**
  27816. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27817. */
  27818. _modelBoundingInfo: BoundingInfo;
  27819. /**
  27820. * @hidden Particle BoundingInfo object (Internal use)
  27821. */
  27822. _boundingInfo: BoundingInfo;
  27823. /**
  27824. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27825. */
  27826. _sps: SolidParticleSystem;
  27827. /**
  27828. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27829. */
  27830. _stillInvisible: boolean;
  27831. /**
  27832. * @hidden Last computed particle rotation matrix
  27833. */
  27834. _rotationMatrix: number[];
  27835. /**
  27836. * Parent particle Id, if any.
  27837. * Default null.
  27838. */
  27839. parentId: Nullable<number>;
  27840. /**
  27841. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27842. */
  27843. materialIndex: Nullable<number>;
  27844. /**
  27845. * Custom object or properties.
  27846. */
  27847. props: Nullable<any>;
  27848. /**
  27849. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27850. * The possible values are :
  27851. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27852. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27853. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27854. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27855. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27856. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27857. * */
  27858. cullingStrategy: number;
  27859. /**
  27860. * @hidden Internal global position in the SPS.
  27861. */
  27862. _globalPosition: Vector3;
  27863. /**
  27864. * Creates a Solid Particle object.
  27865. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27866. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27867. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27868. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27869. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27870. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27871. * @param shapeId (integer) is the model shape identifier in the SPS.
  27872. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27873. * @param sps defines the sps it is associated to
  27874. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27875. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27876. */
  27877. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27878. /**
  27879. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27880. * @param target the particle target
  27881. * @returns the current particle
  27882. */
  27883. copyToRef(target: SolidParticle): SolidParticle;
  27884. /**
  27885. * Legacy support, changed scale to scaling
  27886. */
  27887. get scale(): Vector3;
  27888. /**
  27889. * Legacy support, changed scale to scaling
  27890. */
  27891. set scale(scale: Vector3);
  27892. /**
  27893. * Legacy support, changed quaternion to rotationQuaternion
  27894. */
  27895. get quaternion(): Nullable<Quaternion>;
  27896. /**
  27897. * Legacy support, changed quaternion to rotationQuaternion
  27898. */
  27899. set quaternion(q: Nullable<Quaternion>);
  27900. /**
  27901. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27902. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27903. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27904. * @returns true if it intersects
  27905. */
  27906. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27907. /**
  27908. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27909. * A particle is in the frustum if its bounding box intersects the frustum
  27910. * @param frustumPlanes defines the frustum to test
  27911. * @returns true if the particle is in the frustum planes
  27912. */
  27913. isInFrustum(frustumPlanes: Plane[]): boolean;
  27914. /**
  27915. * get the rotation matrix of the particle
  27916. * @hidden
  27917. */
  27918. getRotationMatrix(m: Matrix): void;
  27919. }
  27920. /**
  27921. * Represents the shape of the model used by one particle of a solid particle system.
  27922. * SPS internal tool, don't use it manually.
  27923. */
  27924. export class ModelShape {
  27925. /**
  27926. * The shape id
  27927. * @hidden
  27928. */
  27929. shapeID: number;
  27930. /**
  27931. * flat array of model positions (internal use)
  27932. * @hidden
  27933. */
  27934. _shape: Vector3[];
  27935. /**
  27936. * flat array of model UVs (internal use)
  27937. * @hidden
  27938. */
  27939. _shapeUV: number[];
  27940. /**
  27941. * color array of the model
  27942. * @hidden
  27943. */
  27944. _shapeColors: number[];
  27945. /**
  27946. * indices array of the model
  27947. * @hidden
  27948. */
  27949. _indices: number[];
  27950. /**
  27951. * normals array of the model
  27952. * @hidden
  27953. */
  27954. _normals: number[];
  27955. /**
  27956. * length of the shape in the model indices array (internal use)
  27957. * @hidden
  27958. */
  27959. _indicesLength: number;
  27960. /**
  27961. * Custom position function (internal use)
  27962. * @hidden
  27963. */
  27964. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27965. /**
  27966. * Custom vertex function (internal use)
  27967. * @hidden
  27968. */
  27969. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27970. /**
  27971. * Model material (internal use)
  27972. * @hidden
  27973. */
  27974. _material: Nullable<Material>;
  27975. /**
  27976. * 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.
  27977. * SPS internal tool, don't use it manually.
  27978. * @hidden
  27979. */
  27980. 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>);
  27981. }
  27982. /**
  27983. * Represents a Depth Sorted Particle in the solid particle system.
  27984. * @hidden
  27985. */
  27986. export class DepthSortedParticle {
  27987. /**
  27988. * Particle index
  27989. */
  27990. idx: number;
  27991. /**
  27992. * Index of the particle in the "indices" array
  27993. */
  27994. ind: number;
  27995. /**
  27996. * Length of the particle shape in the "indices" array
  27997. */
  27998. indicesLength: number;
  27999. /**
  28000. * Squared distance from the particle to the camera
  28001. */
  28002. sqDistance: number;
  28003. /**
  28004. * Material index when used with MultiMaterials
  28005. */
  28006. materialIndex: number;
  28007. /**
  28008. * Creates a new sorted particle
  28009. * @param materialIndex
  28010. */
  28011. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28012. }
  28013. }
  28014. declare module BABYLON {
  28015. /**
  28016. * @hidden
  28017. */
  28018. export class _MeshCollisionData {
  28019. _checkCollisions: boolean;
  28020. _collisionMask: number;
  28021. _collisionGroup: number;
  28022. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28023. _collider: Nullable<Collider>;
  28024. _oldPositionForCollisions: Vector3;
  28025. _diffPositionForCollisions: Vector3;
  28026. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28027. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28028. }
  28029. }
  28030. declare module BABYLON {
  28031. /** @hidden */
  28032. class _FacetDataStorage {
  28033. facetPositions: Vector3[];
  28034. facetNormals: Vector3[];
  28035. facetPartitioning: number[][];
  28036. facetNb: number;
  28037. partitioningSubdivisions: number;
  28038. partitioningBBoxRatio: number;
  28039. facetDataEnabled: boolean;
  28040. facetParameters: any;
  28041. bbSize: Vector3;
  28042. subDiv: {
  28043. max: number;
  28044. X: number;
  28045. Y: number;
  28046. Z: number;
  28047. };
  28048. facetDepthSort: boolean;
  28049. facetDepthSortEnabled: boolean;
  28050. depthSortedIndices: IndicesArray;
  28051. depthSortedFacets: {
  28052. ind: number;
  28053. sqDistance: number;
  28054. }[];
  28055. facetDepthSortFunction: (f1: {
  28056. ind: number;
  28057. sqDistance: number;
  28058. }, f2: {
  28059. ind: number;
  28060. sqDistance: number;
  28061. }) => number;
  28062. facetDepthSortFrom: Vector3;
  28063. facetDepthSortOrigin: Vector3;
  28064. invertedMatrix: Matrix;
  28065. }
  28066. /**
  28067. * @hidden
  28068. **/
  28069. class _InternalAbstractMeshDataInfo {
  28070. _hasVertexAlpha: boolean;
  28071. _useVertexColors: boolean;
  28072. _numBoneInfluencers: number;
  28073. _applyFog: boolean;
  28074. _receiveShadows: boolean;
  28075. _facetData: _FacetDataStorage;
  28076. _visibility: number;
  28077. _skeleton: Nullable<Skeleton>;
  28078. _layerMask: number;
  28079. _computeBonesUsingShaders: boolean;
  28080. _isActive: boolean;
  28081. _onlyForInstances: boolean;
  28082. _isActiveIntermediate: boolean;
  28083. _onlyForInstancesIntermediate: boolean;
  28084. _actAsRegularMesh: boolean;
  28085. }
  28086. /**
  28087. * Class used to store all common mesh properties
  28088. */
  28089. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28090. /** No occlusion */
  28091. static OCCLUSION_TYPE_NONE: number;
  28092. /** Occlusion set to optimisitic */
  28093. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28094. /** Occlusion set to strict */
  28095. static OCCLUSION_TYPE_STRICT: number;
  28096. /** Use an accurante occlusion algorithm */
  28097. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28098. /** Use a conservative occlusion algorithm */
  28099. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28100. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28101. * Test order :
  28102. * Is the bounding sphere outside the frustum ?
  28103. * If not, are the bounding box vertices outside the frustum ?
  28104. * It not, then the cullable object is in the frustum.
  28105. */
  28106. static readonly CULLINGSTRATEGY_STANDARD: number;
  28107. /** Culling strategy : Bounding Sphere Only.
  28108. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28109. * It's also less accurate than the standard because some not visible objects can still be selected.
  28110. * Test : is the bounding sphere outside the frustum ?
  28111. * If not, then the cullable object is in the frustum.
  28112. */
  28113. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28114. /** Culling strategy : Optimistic Inclusion.
  28115. * This in an inclusion test first, then the standard exclusion test.
  28116. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28117. * 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.
  28118. * Anyway, it's as accurate as the standard strategy.
  28119. * Test :
  28120. * Is the cullable object bounding sphere center in the frustum ?
  28121. * If not, apply the default culling strategy.
  28122. */
  28123. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28124. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28125. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28126. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28127. * 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.
  28128. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28129. * Test :
  28130. * Is the cullable object bounding sphere center in the frustum ?
  28131. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28132. */
  28133. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28134. /**
  28135. * No billboard
  28136. */
  28137. static get BILLBOARDMODE_NONE(): number;
  28138. /** Billboard on X axis */
  28139. static get BILLBOARDMODE_X(): number;
  28140. /** Billboard on Y axis */
  28141. static get BILLBOARDMODE_Y(): number;
  28142. /** Billboard on Z axis */
  28143. static get BILLBOARDMODE_Z(): number;
  28144. /** Billboard on all axes */
  28145. static get BILLBOARDMODE_ALL(): number;
  28146. /** Billboard on using position instead of orientation */
  28147. static get BILLBOARDMODE_USE_POSITION(): number;
  28148. /** @hidden */
  28149. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28150. /**
  28151. * The culling strategy to use to check whether the mesh must be rendered or not.
  28152. * This value can be changed at any time and will be used on the next render mesh selection.
  28153. * The possible values are :
  28154. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28155. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28156. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28157. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28158. * Please read each static variable documentation to get details about the culling process.
  28159. * */
  28160. cullingStrategy: number;
  28161. /**
  28162. * Gets the number of facets in the mesh
  28163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28164. */
  28165. get facetNb(): number;
  28166. /**
  28167. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28169. */
  28170. get partitioningSubdivisions(): number;
  28171. set partitioningSubdivisions(nb: number);
  28172. /**
  28173. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28174. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28176. */
  28177. get partitioningBBoxRatio(): number;
  28178. set partitioningBBoxRatio(ratio: number);
  28179. /**
  28180. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28181. * Works only for updatable meshes.
  28182. * Doesn't work with multi-materials
  28183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28184. */
  28185. get mustDepthSortFacets(): boolean;
  28186. set mustDepthSortFacets(sort: boolean);
  28187. /**
  28188. * The location (Vector3) where the facet depth sort must be computed from.
  28189. * By default, the active camera position.
  28190. * Used only when facet depth sort is enabled
  28191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28192. */
  28193. get facetDepthSortFrom(): Vector3;
  28194. set facetDepthSortFrom(location: Vector3);
  28195. /**
  28196. * gets a boolean indicating if facetData is enabled
  28197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28198. */
  28199. get isFacetDataEnabled(): boolean;
  28200. /** @hidden */
  28201. _updateNonUniformScalingState(value: boolean): boolean;
  28202. /**
  28203. * An event triggered when this mesh collides with another one
  28204. */
  28205. onCollideObservable: Observable<AbstractMesh>;
  28206. /** Set a function to call when this mesh collides with another one */
  28207. set onCollide(callback: () => void);
  28208. /**
  28209. * An event triggered when the collision's position changes
  28210. */
  28211. onCollisionPositionChangeObservable: Observable<Vector3>;
  28212. /** Set a function to call when the collision's position changes */
  28213. set onCollisionPositionChange(callback: () => void);
  28214. /**
  28215. * An event triggered when material is changed
  28216. */
  28217. onMaterialChangedObservable: Observable<AbstractMesh>;
  28218. /**
  28219. * Gets or sets the orientation for POV movement & rotation
  28220. */
  28221. definedFacingForward: boolean;
  28222. /** @hidden */
  28223. _occlusionQuery: Nullable<WebGLQuery>;
  28224. /** @hidden */
  28225. _renderingGroup: Nullable<RenderingGroup>;
  28226. /**
  28227. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28228. */
  28229. get visibility(): number;
  28230. /**
  28231. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28232. */
  28233. set visibility(value: number);
  28234. /** Gets or sets the alpha index used to sort transparent meshes
  28235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28236. */
  28237. alphaIndex: number;
  28238. /**
  28239. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28240. */
  28241. isVisible: boolean;
  28242. /**
  28243. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28244. */
  28245. isPickable: boolean;
  28246. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28247. showSubMeshesBoundingBox: boolean;
  28248. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28249. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28250. */
  28251. isBlocker: boolean;
  28252. /**
  28253. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28254. */
  28255. enablePointerMoveEvents: boolean;
  28256. /**
  28257. * Specifies the rendering group id for this mesh (0 by default)
  28258. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28259. */
  28260. renderingGroupId: number;
  28261. private _material;
  28262. /** Gets or sets current material */
  28263. get material(): Nullable<Material>;
  28264. set material(value: Nullable<Material>);
  28265. /**
  28266. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28267. * @see http://doc.babylonjs.com/babylon101/shadows
  28268. */
  28269. get receiveShadows(): boolean;
  28270. set receiveShadows(value: boolean);
  28271. /** Defines color to use when rendering outline */
  28272. outlineColor: Color3;
  28273. /** Define width to use when rendering outline */
  28274. outlineWidth: number;
  28275. /** Defines color to use when rendering overlay */
  28276. overlayColor: Color3;
  28277. /** Defines alpha to use when rendering overlay */
  28278. overlayAlpha: number;
  28279. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28280. get hasVertexAlpha(): boolean;
  28281. set hasVertexAlpha(value: boolean);
  28282. /** 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) */
  28283. get useVertexColors(): boolean;
  28284. set useVertexColors(value: boolean);
  28285. /**
  28286. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28287. */
  28288. get computeBonesUsingShaders(): boolean;
  28289. set computeBonesUsingShaders(value: boolean);
  28290. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28291. get numBoneInfluencers(): number;
  28292. set numBoneInfluencers(value: number);
  28293. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28294. get applyFog(): boolean;
  28295. set applyFog(value: boolean);
  28296. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28297. useOctreeForRenderingSelection: boolean;
  28298. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28299. useOctreeForPicking: boolean;
  28300. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28301. useOctreeForCollisions: boolean;
  28302. /**
  28303. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28304. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28305. */
  28306. get layerMask(): number;
  28307. set layerMask(value: number);
  28308. /**
  28309. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28310. */
  28311. alwaysSelectAsActiveMesh: boolean;
  28312. /**
  28313. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28314. */
  28315. doNotSyncBoundingInfo: boolean;
  28316. /**
  28317. * Gets or sets the current action manager
  28318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28319. */
  28320. actionManager: Nullable<AbstractActionManager>;
  28321. private _meshCollisionData;
  28322. /**
  28323. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28325. */
  28326. ellipsoid: Vector3;
  28327. /**
  28328. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28330. */
  28331. ellipsoidOffset: Vector3;
  28332. /**
  28333. * Gets or sets a collision mask used to mask collisions (default is -1).
  28334. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28335. */
  28336. get collisionMask(): number;
  28337. set collisionMask(mask: number);
  28338. /**
  28339. * Gets or sets the current collision group mask (-1 by default).
  28340. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28341. */
  28342. get collisionGroup(): number;
  28343. set collisionGroup(mask: number);
  28344. /**
  28345. * Gets or sets current surrounding meshes (null by default).
  28346. *
  28347. * By default collision detection is tested against every mesh in the scene.
  28348. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28349. * meshes will be tested for the collision.
  28350. *
  28351. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28352. */
  28353. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28354. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28355. /**
  28356. * Defines edge width used when edgesRenderer is enabled
  28357. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28358. */
  28359. edgesWidth: number;
  28360. /**
  28361. * Defines edge color used when edgesRenderer is enabled
  28362. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28363. */
  28364. edgesColor: Color4;
  28365. /** @hidden */
  28366. _edgesRenderer: Nullable<IEdgesRenderer>;
  28367. /** @hidden */
  28368. _masterMesh: Nullable<AbstractMesh>;
  28369. /** @hidden */
  28370. _boundingInfo: Nullable<BoundingInfo>;
  28371. /** @hidden */
  28372. _renderId: number;
  28373. /**
  28374. * Gets or sets the list of subMeshes
  28375. * @see http://doc.babylonjs.com/how_to/multi_materials
  28376. */
  28377. subMeshes: SubMesh[];
  28378. /** @hidden */
  28379. _intersectionsInProgress: AbstractMesh[];
  28380. /** @hidden */
  28381. _unIndexed: boolean;
  28382. /** @hidden */
  28383. _lightSources: Light[];
  28384. /** Gets the list of lights affecting that mesh */
  28385. get lightSources(): Light[];
  28386. /** @hidden */
  28387. get _positions(): Nullable<Vector3[]>;
  28388. /** @hidden */
  28389. _waitingData: {
  28390. lods: Nullable<any>;
  28391. actions: Nullable<any>;
  28392. freezeWorldMatrix: Nullable<boolean>;
  28393. };
  28394. /** @hidden */
  28395. _bonesTransformMatrices: Nullable<Float32Array>;
  28396. /** @hidden */
  28397. _transformMatrixTexture: Nullable<RawTexture>;
  28398. /**
  28399. * Gets or sets a skeleton to apply skining transformations
  28400. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28401. */
  28402. set skeleton(value: Nullable<Skeleton>);
  28403. get skeleton(): Nullable<Skeleton>;
  28404. /**
  28405. * An event triggered when the mesh is rebuilt.
  28406. */
  28407. onRebuildObservable: Observable<AbstractMesh>;
  28408. /**
  28409. * Creates a new AbstractMesh
  28410. * @param name defines the name of the mesh
  28411. * @param scene defines the hosting scene
  28412. */
  28413. constructor(name: string, scene?: Nullable<Scene>);
  28414. /**
  28415. * Returns the string "AbstractMesh"
  28416. * @returns "AbstractMesh"
  28417. */
  28418. getClassName(): string;
  28419. /**
  28420. * Gets a string representation of the current mesh
  28421. * @param fullDetails defines a boolean indicating if full details must be included
  28422. * @returns a string representation of the current mesh
  28423. */
  28424. toString(fullDetails?: boolean): string;
  28425. /**
  28426. * @hidden
  28427. */
  28428. protected _getEffectiveParent(): Nullable<Node>;
  28429. /** @hidden */
  28430. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28431. /** @hidden */
  28432. _rebuild(): void;
  28433. /** @hidden */
  28434. _resyncLightSources(): void;
  28435. /** @hidden */
  28436. _resyncLightSource(light: Light): void;
  28437. /** @hidden */
  28438. _unBindEffect(): void;
  28439. /** @hidden */
  28440. _removeLightSource(light: Light, dispose: boolean): void;
  28441. private _markSubMeshesAsDirty;
  28442. /** @hidden */
  28443. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28444. /** @hidden */
  28445. _markSubMeshesAsAttributesDirty(): void;
  28446. /** @hidden */
  28447. _markSubMeshesAsMiscDirty(): void;
  28448. /**
  28449. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28450. */
  28451. get scaling(): Vector3;
  28452. set scaling(newScaling: Vector3);
  28453. /**
  28454. * Returns true if the mesh is blocked. Implemented by child classes
  28455. */
  28456. get isBlocked(): boolean;
  28457. /**
  28458. * Returns the mesh itself by default. Implemented by child classes
  28459. * @param camera defines the camera to use to pick the right LOD level
  28460. * @returns the currentAbstractMesh
  28461. */
  28462. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28463. /**
  28464. * Returns 0 by default. Implemented by child classes
  28465. * @returns an integer
  28466. */
  28467. getTotalVertices(): number;
  28468. /**
  28469. * Returns a positive integer : the total number of indices in this mesh geometry.
  28470. * @returns the numner of indices or zero if the mesh has no geometry.
  28471. */
  28472. getTotalIndices(): number;
  28473. /**
  28474. * Returns null by default. Implemented by child classes
  28475. * @returns null
  28476. */
  28477. getIndices(): Nullable<IndicesArray>;
  28478. /**
  28479. * Returns the array of the requested vertex data kind. Implemented by child classes
  28480. * @param kind defines the vertex data kind to use
  28481. * @returns null
  28482. */
  28483. getVerticesData(kind: string): Nullable<FloatArray>;
  28484. /**
  28485. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28486. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28487. * Note that a new underlying VertexBuffer object is created each call.
  28488. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28489. * @param kind defines vertex data kind:
  28490. * * VertexBuffer.PositionKind
  28491. * * VertexBuffer.UVKind
  28492. * * VertexBuffer.UV2Kind
  28493. * * VertexBuffer.UV3Kind
  28494. * * VertexBuffer.UV4Kind
  28495. * * VertexBuffer.UV5Kind
  28496. * * VertexBuffer.UV6Kind
  28497. * * VertexBuffer.ColorKind
  28498. * * VertexBuffer.MatricesIndicesKind
  28499. * * VertexBuffer.MatricesIndicesExtraKind
  28500. * * VertexBuffer.MatricesWeightsKind
  28501. * * VertexBuffer.MatricesWeightsExtraKind
  28502. * @param data defines the data source
  28503. * @param updatable defines if the data must be flagged as updatable (or static)
  28504. * @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
  28505. * @returns the current mesh
  28506. */
  28507. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28508. /**
  28509. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28510. * If the mesh has no geometry, it is simply returned as it is.
  28511. * @param kind defines vertex data kind:
  28512. * * VertexBuffer.PositionKind
  28513. * * VertexBuffer.UVKind
  28514. * * VertexBuffer.UV2Kind
  28515. * * VertexBuffer.UV3Kind
  28516. * * VertexBuffer.UV4Kind
  28517. * * VertexBuffer.UV5Kind
  28518. * * VertexBuffer.UV6Kind
  28519. * * VertexBuffer.ColorKind
  28520. * * VertexBuffer.MatricesIndicesKind
  28521. * * VertexBuffer.MatricesIndicesExtraKind
  28522. * * VertexBuffer.MatricesWeightsKind
  28523. * * VertexBuffer.MatricesWeightsExtraKind
  28524. * @param data defines the data source
  28525. * @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
  28526. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28527. * @returns the current mesh
  28528. */
  28529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28530. /**
  28531. * Sets the mesh indices,
  28532. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28533. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28534. * @param totalVertices Defines the total number of vertices
  28535. * @returns the current mesh
  28536. */
  28537. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28538. /**
  28539. * Gets a boolean indicating if specific vertex data is present
  28540. * @param kind defines the vertex data kind to use
  28541. * @returns true is data kind is present
  28542. */
  28543. isVerticesDataPresent(kind: string): boolean;
  28544. /**
  28545. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28546. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28547. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28548. * @returns a BoundingInfo
  28549. */
  28550. getBoundingInfo(): BoundingInfo;
  28551. /**
  28552. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28553. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28554. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28555. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28556. * @returns the current mesh
  28557. */
  28558. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28559. /**
  28560. * Overwrite the current bounding info
  28561. * @param boundingInfo defines the new bounding info
  28562. * @returns the current mesh
  28563. */
  28564. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28565. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28566. get useBones(): boolean;
  28567. /** @hidden */
  28568. _preActivate(): void;
  28569. /** @hidden */
  28570. _preActivateForIntermediateRendering(renderId: number): void;
  28571. /** @hidden */
  28572. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28573. /** @hidden */
  28574. _postActivate(): void;
  28575. /** @hidden */
  28576. _freeze(): void;
  28577. /** @hidden */
  28578. _unFreeze(): void;
  28579. /**
  28580. * Gets the current world matrix
  28581. * @returns a Matrix
  28582. */
  28583. getWorldMatrix(): Matrix;
  28584. /** @hidden */
  28585. _getWorldMatrixDeterminant(): number;
  28586. /**
  28587. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28588. */
  28589. get isAnInstance(): boolean;
  28590. /**
  28591. * Gets a boolean indicating if this mesh has instances
  28592. */
  28593. get hasInstances(): boolean;
  28594. /**
  28595. * Perform relative position change from the point of view of behind the front of the mesh.
  28596. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28597. * Supports definition of mesh facing forward or backward
  28598. * @param amountRight defines the distance on the right axis
  28599. * @param amountUp defines the distance on the up axis
  28600. * @param amountForward defines the distance on the forward axis
  28601. * @returns the current mesh
  28602. */
  28603. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28604. /**
  28605. * Calculate relative position change from the point of view of behind the front of the mesh.
  28606. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28607. * Supports definition of mesh facing forward or backward
  28608. * @param amountRight defines the distance on the right axis
  28609. * @param amountUp defines the distance on the up axis
  28610. * @param amountForward defines the distance on the forward axis
  28611. * @returns the new displacement vector
  28612. */
  28613. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28614. /**
  28615. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28616. * Supports definition of mesh facing forward or backward
  28617. * @param flipBack defines the flip
  28618. * @param twirlClockwise defines the twirl
  28619. * @param tiltRight defines the tilt
  28620. * @returns the current mesh
  28621. */
  28622. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28623. /**
  28624. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28625. * Supports definition of mesh facing forward or backward.
  28626. * @param flipBack defines the flip
  28627. * @param twirlClockwise defines the twirl
  28628. * @param tiltRight defines the tilt
  28629. * @returns the new rotation vector
  28630. */
  28631. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28632. /**
  28633. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28634. * This means the mesh underlying bounding box and sphere are recomputed.
  28635. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28636. * @returns the current mesh
  28637. */
  28638. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28639. /** @hidden */
  28640. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28641. /** @hidden */
  28642. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28643. /** @hidden */
  28644. _updateBoundingInfo(): AbstractMesh;
  28645. /** @hidden */
  28646. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28647. /** @hidden */
  28648. protected _afterComputeWorldMatrix(): void;
  28649. /** @hidden */
  28650. get _effectiveMesh(): AbstractMesh;
  28651. /**
  28652. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28653. * A mesh is in the frustum if its bounding box intersects the frustum
  28654. * @param frustumPlanes defines the frustum to test
  28655. * @returns true if the mesh is in the frustum planes
  28656. */
  28657. isInFrustum(frustumPlanes: Plane[]): boolean;
  28658. /**
  28659. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28660. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28661. * @param frustumPlanes defines the frustum to test
  28662. * @returns true if the mesh is completely in the frustum planes
  28663. */
  28664. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28665. /**
  28666. * True if the mesh intersects another mesh or a SolidParticle object
  28667. * @param mesh defines a target mesh or SolidParticle to test
  28668. * @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)
  28669. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28670. * @returns true if there is an intersection
  28671. */
  28672. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28673. /**
  28674. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28675. * @param point defines the point to test
  28676. * @returns true if there is an intersection
  28677. */
  28678. intersectsPoint(point: Vector3): boolean;
  28679. /**
  28680. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28681. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28682. */
  28683. get checkCollisions(): boolean;
  28684. set checkCollisions(collisionEnabled: boolean);
  28685. /**
  28686. * Gets Collider object used to compute collisions (not physics)
  28687. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28688. */
  28689. get collider(): Nullable<Collider>;
  28690. /**
  28691. * Move the mesh using collision engine
  28692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28693. * @param displacement defines the requested displacement vector
  28694. * @returns the current mesh
  28695. */
  28696. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28697. private _onCollisionPositionChange;
  28698. /** @hidden */
  28699. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28700. /** @hidden */
  28701. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28702. /** @hidden */
  28703. _checkCollision(collider: Collider): AbstractMesh;
  28704. /** @hidden */
  28705. _generatePointsArray(): boolean;
  28706. /**
  28707. * Checks if the passed Ray intersects with the mesh
  28708. * @param ray defines the ray to use
  28709. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28711. * @returns the picking info
  28712. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28713. */
  28714. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28715. /**
  28716. * Clones the current mesh
  28717. * @param name defines the mesh name
  28718. * @param newParent defines the new mesh parent
  28719. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28720. * @returns the new mesh
  28721. */
  28722. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28723. /**
  28724. * Disposes all the submeshes of the current meshnp
  28725. * @returns the current mesh
  28726. */
  28727. releaseSubMeshes(): AbstractMesh;
  28728. /**
  28729. * Releases resources associated with this abstract mesh.
  28730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28732. */
  28733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28734. /**
  28735. * Adds the passed mesh as a child to the current mesh
  28736. * @param mesh defines the child mesh
  28737. * @returns the current mesh
  28738. */
  28739. addChild(mesh: AbstractMesh): AbstractMesh;
  28740. /**
  28741. * Removes the passed mesh from the current mesh children list
  28742. * @param mesh defines the child mesh
  28743. * @returns the current mesh
  28744. */
  28745. removeChild(mesh: AbstractMesh): AbstractMesh;
  28746. /** @hidden */
  28747. private _initFacetData;
  28748. /**
  28749. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28750. * This method can be called within the render loop.
  28751. * 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
  28752. * @returns the current mesh
  28753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28754. */
  28755. updateFacetData(): AbstractMesh;
  28756. /**
  28757. * Returns the facetLocalNormals array.
  28758. * The normals are expressed in the mesh local spac
  28759. * @returns an array of Vector3
  28760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28761. */
  28762. getFacetLocalNormals(): Vector3[];
  28763. /**
  28764. * Returns the facetLocalPositions array.
  28765. * The facet positions are expressed in the mesh local space
  28766. * @returns an array of Vector3
  28767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28768. */
  28769. getFacetLocalPositions(): Vector3[];
  28770. /**
  28771. * Returns the facetLocalPartioning array
  28772. * @returns an array of array of numbers
  28773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28774. */
  28775. getFacetLocalPartitioning(): number[][];
  28776. /**
  28777. * Returns the i-th facet position in the world system.
  28778. * This method allocates a new Vector3 per call
  28779. * @param i defines the facet index
  28780. * @returns a new Vector3
  28781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28782. */
  28783. getFacetPosition(i: number): Vector3;
  28784. /**
  28785. * Sets the reference Vector3 with the i-th facet position in the world system
  28786. * @param i defines the facet index
  28787. * @param ref defines the target vector
  28788. * @returns the current mesh
  28789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28790. */
  28791. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28792. /**
  28793. * Returns the i-th facet normal in the world system.
  28794. * This method allocates a new Vector3 per call
  28795. * @param i defines the facet index
  28796. * @returns a new Vector3
  28797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28798. */
  28799. getFacetNormal(i: number): Vector3;
  28800. /**
  28801. * Sets the reference Vector3 with the i-th facet normal in the world system
  28802. * @param i defines the facet index
  28803. * @param ref defines the target vector
  28804. * @returns the current mesh
  28805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28806. */
  28807. getFacetNormalToRef(i: number, ref: Vector3): this;
  28808. /**
  28809. * 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)
  28810. * @param x defines x coordinate
  28811. * @param y defines y coordinate
  28812. * @param z defines z coordinate
  28813. * @returns the array of facet indexes
  28814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28815. */
  28816. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28817. /**
  28818. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28819. * @param projected sets as the (x,y,z) world projection on the facet
  28820. * @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
  28821. * @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
  28822. * @param x defines x coordinate
  28823. * @param y defines y coordinate
  28824. * @param z defines z coordinate
  28825. * @returns the face index if found (or null instead)
  28826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28827. */
  28828. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28829. /**
  28830. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28831. * @param projected sets as the (x,y,z) local projection on the facet
  28832. * @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
  28833. * @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
  28834. * @param x defines x coordinate
  28835. * @param y defines y coordinate
  28836. * @param z defines z coordinate
  28837. * @returns the face index if found (or null instead)
  28838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28839. */
  28840. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28841. /**
  28842. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28843. * @returns the parameters
  28844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28845. */
  28846. getFacetDataParameters(): any;
  28847. /**
  28848. * Disables the feature FacetData and frees the related memory
  28849. * @returns the current mesh
  28850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28851. */
  28852. disableFacetData(): AbstractMesh;
  28853. /**
  28854. * Updates the AbstractMesh indices array
  28855. * @param indices defines the data source
  28856. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28857. * @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)
  28858. * @returns the current mesh
  28859. */
  28860. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28861. /**
  28862. * Creates new normals data for the mesh
  28863. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28864. * @returns the current mesh
  28865. */
  28866. createNormals(updatable: boolean): AbstractMesh;
  28867. /**
  28868. * Align the mesh with a normal
  28869. * @param normal defines the normal to use
  28870. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28871. * @returns the current mesh
  28872. */
  28873. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28874. /** @hidden */
  28875. _checkOcclusionQuery(): boolean;
  28876. /**
  28877. * Disables the mesh edge rendering mode
  28878. * @returns the currentAbstractMesh
  28879. */
  28880. disableEdgesRendering(): AbstractMesh;
  28881. /**
  28882. * Enables the edge rendering mode on the mesh.
  28883. * This mode makes the mesh edges visible
  28884. * @param epsilon defines the maximal distance between two angles to detect a face
  28885. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28886. * @returns the currentAbstractMesh
  28887. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28888. */
  28889. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28890. }
  28891. }
  28892. declare module BABYLON {
  28893. /**
  28894. * Interface used to define ActionEvent
  28895. */
  28896. export interface IActionEvent {
  28897. /** The mesh or sprite that triggered the action */
  28898. source: any;
  28899. /** The X mouse cursor position at the time of the event */
  28900. pointerX: number;
  28901. /** The Y mouse cursor position at the time of the event */
  28902. pointerY: number;
  28903. /** The mesh that is currently pointed at (can be null) */
  28904. meshUnderPointer: Nullable<AbstractMesh>;
  28905. /** the original (browser) event that triggered the ActionEvent */
  28906. sourceEvent?: any;
  28907. /** additional data for the event */
  28908. additionalData?: any;
  28909. }
  28910. /**
  28911. * ActionEvent is the event being sent when an action is triggered.
  28912. */
  28913. export class ActionEvent implements IActionEvent {
  28914. /** The mesh or sprite that triggered the action */
  28915. source: any;
  28916. /** The X mouse cursor position at the time of the event */
  28917. pointerX: number;
  28918. /** The Y mouse cursor position at the time of the event */
  28919. pointerY: number;
  28920. /** The mesh that is currently pointed at (can be null) */
  28921. meshUnderPointer: Nullable<AbstractMesh>;
  28922. /** the original (browser) event that triggered the ActionEvent */
  28923. sourceEvent?: any;
  28924. /** additional data for the event */
  28925. additionalData?: any;
  28926. /**
  28927. * Creates a new ActionEvent
  28928. * @param source The mesh or sprite that triggered the action
  28929. * @param pointerX The X mouse cursor position at the time of the event
  28930. * @param pointerY The Y mouse cursor position at the time of the event
  28931. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28932. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28933. * @param additionalData additional data for the event
  28934. */
  28935. constructor(
  28936. /** The mesh or sprite that triggered the action */
  28937. source: any,
  28938. /** The X mouse cursor position at the time of the event */
  28939. pointerX: number,
  28940. /** The Y mouse cursor position at the time of the event */
  28941. pointerY: number,
  28942. /** The mesh that is currently pointed at (can be null) */
  28943. meshUnderPointer: Nullable<AbstractMesh>,
  28944. /** the original (browser) event that triggered the ActionEvent */
  28945. sourceEvent?: any,
  28946. /** additional data for the event */
  28947. additionalData?: any);
  28948. /**
  28949. * Helper function to auto-create an ActionEvent from a source mesh.
  28950. * @param source The source mesh that triggered the event
  28951. * @param evt The original (browser) event
  28952. * @param additionalData additional data for the event
  28953. * @returns the new ActionEvent
  28954. */
  28955. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28956. /**
  28957. * Helper function to auto-create an ActionEvent from a source sprite
  28958. * @param source The source sprite that triggered the event
  28959. * @param scene Scene associated with the sprite
  28960. * @param evt The original (browser) event
  28961. * @param additionalData additional data for the event
  28962. * @returns the new ActionEvent
  28963. */
  28964. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28965. /**
  28966. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28967. * @param scene the scene where the event occurred
  28968. * @param evt The original (browser) event
  28969. * @returns the new ActionEvent
  28970. */
  28971. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28972. /**
  28973. * Helper function to auto-create an ActionEvent from a primitive
  28974. * @param prim defines the target primitive
  28975. * @param pointerPos defines the pointer position
  28976. * @param evt The original (browser) event
  28977. * @param additionalData additional data for the event
  28978. * @returns the new ActionEvent
  28979. */
  28980. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28981. }
  28982. }
  28983. declare module BABYLON {
  28984. /**
  28985. * Abstract class used to decouple action Manager from scene and meshes.
  28986. * Do not instantiate.
  28987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28988. */
  28989. export abstract class AbstractActionManager implements IDisposable {
  28990. /** Gets the list of active triggers */
  28991. static Triggers: {
  28992. [key: string]: number;
  28993. };
  28994. /** Gets the cursor to use when hovering items */
  28995. hoverCursor: string;
  28996. /** Gets the list of actions */
  28997. actions: IAction[];
  28998. /**
  28999. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29000. */
  29001. isRecursive: boolean;
  29002. /**
  29003. * Releases all associated resources
  29004. */
  29005. abstract dispose(): void;
  29006. /**
  29007. * Does this action manager has pointer triggers
  29008. */
  29009. abstract get hasPointerTriggers(): boolean;
  29010. /**
  29011. * Does this action manager has pick triggers
  29012. */
  29013. abstract get hasPickTriggers(): boolean;
  29014. /**
  29015. * Process a specific trigger
  29016. * @param trigger defines the trigger to process
  29017. * @param evt defines the event details to be processed
  29018. */
  29019. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29020. /**
  29021. * Does this action manager handles actions of any of the given triggers
  29022. * @param triggers defines the triggers to be tested
  29023. * @return a boolean indicating whether one (or more) of the triggers is handled
  29024. */
  29025. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29026. /**
  29027. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29028. * speed.
  29029. * @param triggerA defines the trigger to be tested
  29030. * @param triggerB defines the trigger to be tested
  29031. * @return a boolean indicating whether one (or more) of the triggers is handled
  29032. */
  29033. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29034. /**
  29035. * Does this action manager handles actions of a given trigger
  29036. * @param trigger defines the trigger to be tested
  29037. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29038. * @return whether the trigger is handled
  29039. */
  29040. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29041. /**
  29042. * Serialize this manager to a JSON object
  29043. * @param name defines the property name to store this manager
  29044. * @returns a JSON representation of this manager
  29045. */
  29046. abstract serialize(name: string): any;
  29047. /**
  29048. * Registers an action to this action manager
  29049. * @param action defines the action to be registered
  29050. * @return the action amended (prepared) after registration
  29051. */
  29052. abstract registerAction(action: IAction): Nullable<IAction>;
  29053. /**
  29054. * Unregisters an action to this action manager
  29055. * @param action defines the action to be unregistered
  29056. * @return a boolean indicating whether the action has been unregistered
  29057. */
  29058. abstract unregisterAction(action: IAction): Boolean;
  29059. /**
  29060. * Does exist one action manager with at least one trigger
  29061. **/
  29062. static get HasTriggers(): boolean;
  29063. /**
  29064. * Does exist one action manager with at least one pick trigger
  29065. **/
  29066. static get HasPickTriggers(): boolean;
  29067. /**
  29068. * Does exist one action manager that handles actions of a given trigger
  29069. * @param trigger defines the trigger to be tested
  29070. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29071. **/
  29072. static HasSpecificTrigger(trigger: number): boolean;
  29073. }
  29074. }
  29075. declare module BABYLON {
  29076. /**
  29077. * Defines how a node can be built from a string name.
  29078. */
  29079. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29080. /**
  29081. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29082. */
  29083. export class Node implements IBehaviorAware<Node> {
  29084. /** @hidden */
  29085. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29086. private static _NodeConstructors;
  29087. /**
  29088. * Add a new node constructor
  29089. * @param type defines the type name of the node to construct
  29090. * @param constructorFunc defines the constructor function
  29091. */
  29092. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29093. /**
  29094. * Returns a node constructor based on type name
  29095. * @param type defines the type name
  29096. * @param name defines the new node name
  29097. * @param scene defines the hosting scene
  29098. * @param options defines optional options to transmit to constructors
  29099. * @returns the new constructor or null
  29100. */
  29101. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29102. /**
  29103. * Gets or sets the name of the node
  29104. */
  29105. name: string;
  29106. /**
  29107. * Gets or sets the id of the node
  29108. */
  29109. id: string;
  29110. /**
  29111. * Gets or sets the unique id of the node
  29112. */
  29113. uniqueId: number;
  29114. /**
  29115. * Gets or sets a string used to store user defined state for the node
  29116. */
  29117. state: string;
  29118. /**
  29119. * Gets or sets an object used to store user defined information for the node
  29120. */
  29121. metadata: any;
  29122. /**
  29123. * For internal use only. Please do not use.
  29124. */
  29125. reservedDataStore: any;
  29126. /**
  29127. * List of inspectable custom properties (used by the Inspector)
  29128. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29129. */
  29130. inspectableCustomProperties: IInspectable[];
  29131. private _doNotSerialize;
  29132. /**
  29133. * Gets or sets a boolean used to define if the node must be serialized
  29134. */
  29135. get doNotSerialize(): boolean;
  29136. set doNotSerialize(value: boolean);
  29137. /** @hidden */
  29138. _isDisposed: boolean;
  29139. /**
  29140. * Gets a list of Animations associated with the node
  29141. */
  29142. animations: Animation[];
  29143. protected _ranges: {
  29144. [name: string]: Nullable<AnimationRange>;
  29145. };
  29146. /**
  29147. * Callback raised when the node is ready to be used
  29148. */
  29149. onReady: Nullable<(node: Node) => void>;
  29150. private _isEnabled;
  29151. private _isParentEnabled;
  29152. private _isReady;
  29153. /** @hidden */
  29154. _currentRenderId: number;
  29155. private _parentUpdateId;
  29156. /** @hidden */
  29157. _childUpdateId: number;
  29158. /** @hidden */
  29159. _waitingParentId: Nullable<string>;
  29160. /** @hidden */
  29161. _scene: Scene;
  29162. /** @hidden */
  29163. _cache: any;
  29164. private _parentNode;
  29165. private _children;
  29166. /** @hidden */
  29167. _worldMatrix: Matrix;
  29168. /** @hidden */
  29169. _worldMatrixDeterminant: number;
  29170. /** @hidden */
  29171. _worldMatrixDeterminantIsDirty: boolean;
  29172. /** @hidden */
  29173. private _sceneRootNodesIndex;
  29174. /**
  29175. * Gets a boolean indicating if the node has been disposed
  29176. * @returns true if the node was disposed
  29177. */
  29178. isDisposed(): boolean;
  29179. /**
  29180. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29181. * @see https://doc.babylonjs.com/how_to/parenting
  29182. */
  29183. set parent(parent: Nullable<Node>);
  29184. get parent(): Nullable<Node>;
  29185. /** @hidden */
  29186. _addToSceneRootNodes(): void;
  29187. /** @hidden */
  29188. _removeFromSceneRootNodes(): void;
  29189. private _animationPropertiesOverride;
  29190. /**
  29191. * Gets or sets the animation properties override
  29192. */
  29193. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29194. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29195. /**
  29196. * Gets a string idenfifying the name of the class
  29197. * @returns "Node" string
  29198. */
  29199. getClassName(): string;
  29200. /** @hidden */
  29201. readonly _isNode: boolean;
  29202. /**
  29203. * An event triggered when the mesh is disposed
  29204. */
  29205. onDisposeObservable: Observable<Node>;
  29206. private _onDisposeObserver;
  29207. /**
  29208. * Sets a callback that will be raised when the node will be disposed
  29209. */
  29210. set onDispose(callback: () => void);
  29211. /**
  29212. * Creates a new Node
  29213. * @param name the name and id to be given to this node
  29214. * @param scene the scene this node will be added to
  29215. */
  29216. constructor(name: string, scene?: Nullable<Scene>);
  29217. /**
  29218. * Gets the scene of the node
  29219. * @returns a scene
  29220. */
  29221. getScene(): Scene;
  29222. /**
  29223. * Gets the engine of the node
  29224. * @returns a Engine
  29225. */
  29226. getEngine(): Engine;
  29227. private _behaviors;
  29228. /**
  29229. * Attach a behavior to the node
  29230. * @see http://doc.babylonjs.com/features/behaviour
  29231. * @param behavior defines the behavior to attach
  29232. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29233. * @returns the current Node
  29234. */
  29235. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29236. /**
  29237. * Remove an attached behavior
  29238. * @see http://doc.babylonjs.com/features/behaviour
  29239. * @param behavior defines the behavior to attach
  29240. * @returns the current Node
  29241. */
  29242. removeBehavior(behavior: Behavior<Node>): Node;
  29243. /**
  29244. * Gets the list of attached behaviors
  29245. * @see http://doc.babylonjs.com/features/behaviour
  29246. */
  29247. get behaviors(): Behavior<Node>[];
  29248. /**
  29249. * Gets an attached behavior by name
  29250. * @param name defines the name of the behavior to look for
  29251. * @see http://doc.babylonjs.com/features/behaviour
  29252. * @returns null if behavior was not found else the requested behavior
  29253. */
  29254. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29255. /**
  29256. * Returns the latest update of the World matrix
  29257. * @returns a Matrix
  29258. */
  29259. getWorldMatrix(): Matrix;
  29260. /** @hidden */
  29261. _getWorldMatrixDeterminant(): number;
  29262. /**
  29263. * Returns directly the latest state of the mesh World matrix.
  29264. * A Matrix is returned.
  29265. */
  29266. get worldMatrixFromCache(): Matrix;
  29267. /** @hidden */
  29268. _initCache(): void;
  29269. /** @hidden */
  29270. updateCache(force?: boolean): void;
  29271. /** @hidden */
  29272. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29273. /** @hidden */
  29274. _updateCache(ignoreParentClass?: boolean): void;
  29275. /** @hidden */
  29276. _isSynchronized(): boolean;
  29277. /** @hidden */
  29278. _markSyncedWithParent(): void;
  29279. /** @hidden */
  29280. isSynchronizedWithParent(): boolean;
  29281. /** @hidden */
  29282. isSynchronized(): boolean;
  29283. /**
  29284. * Is this node ready to be used/rendered
  29285. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29286. * @return true if the node is ready
  29287. */
  29288. isReady(completeCheck?: boolean): boolean;
  29289. /**
  29290. * Is this node enabled?
  29291. * 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
  29292. * @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
  29293. * @return whether this node (and its parent) is enabled
  29294. */
  29295. isEnabled(checkAncestors?: boolean): boolean;
  29296. /** @hidden */
  29297. protected _syncParentEnabledState(): void;
  29298. /**
  29299. * Set the enabled state of this node
  29300. * @param value defines the new enabled state
  29301. */
  29302. setEnabled(value: boolean): void;
  29303. /**
  29304. * Is this node a descendant of the given node?
  29305. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29306. * @param ancestor defines the parent node to inspect
  29307. * @returns a boolean indicating if this node is a descendant of the given node
  29308. */
  29309. isDescendantOf(ancestor: Node): boolean;
  29310. /** @hidden */
  29311. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29312. /**
  29313. * Will return all nodes that have this node as ascendant
  29314. * @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
  29315. * @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
  29316. * @return all children nodes of all types
  29317. */
  29318. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29319. /**
  29320. * Get all child-meshes of this node
  29321. * @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)
  29322. * @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
  29323. * @returns an array of AbstractMesh
  29324. */
  29325. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29326. /**
  29327. * Get all direct children of this node
  29328. * @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
  29329. * @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)
  29330. * @returns an array of Node
  29331. */
  29332. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29333. /** @hidden */
  29334. _setReady(state: boolean): void;
  29335. /**
  29336. * Get an animation by name
  29337. * @param name defines the name of the animation to look for
  29338. * @returns null if not found else the requested animation
  29339. */
  29340. getAnimationByName(name: string): Nullable<Animation>;
  29341. /**
  29342. * Creates an animation range for this node
  29343. * @param name defines the name of the range
  29344. * @param from defines the starting key
  29345. * @param to defines the end key
  29346. */
  29347. createAnimationRange(name: string, from: number, to: number): void;
  29348. /**
  29349. * Delete a specific animation range
  29350. * @param name defines the name of the range to delete
  29351. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29352. */
  29353. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29354. /**
  29355. * Get an animation range by name
  29356. * @param name defines the name of the animation range to look for
  29357. * @returns null if not found else the requested animation range
  29358. */
  29359. getAnimationRange(name: string): Nullable<AnimationRange>;
  29360. /**
  29361. * Gets the list of all animation ranges defined on this node
  29362. * @returns an array
  29363. */
  29364. getAnimationRanges(): Nullable<AnimationRange>[];
  29365. /**
  29366. * Will start the animation sequence
  29367. * @param name defines the range frames for animation sequence
  29368. * @param loop defines if the animation should loop (false by default)
  29369. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29370. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29371. * @returns the object created for this animation. If range does not exist, it will return null
  29372. */
  29373. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29374. /**
  29375. * Serialize animation ranges into a JSON compatible object
  29376. * @returns serialization object
  29377. */
  29378. serializeAnimationRanges(): any;
  29379. /**
  29380. * Computes the world matrix of the node
  29381. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29382. * @returns the world matrix
  29383. */
  29384. computeWorldMatrix(force?: boolean): Matrix;
  29385. /**
  29386. * Releases resources associated with this node.
  29387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29389. */
  29390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29391. /**
  29392. * Parse animation range data from a serialization object and store them into a given node
  29393. * @param node defines where to store the animation ranges
  29394. * @param parsedNode defines the serialization object to read data from
  29395. * @param scene defines the hosting scene
  29396. */
  29397. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29398. /**
  29399. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29400. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29401. * @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
  29402. * @returns the new bounding vectors
  29403. */
  29404. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29405. min: Vector3;
  29406. max: Vector3;
  29407. };
  29408. }
  29409. }
  29410. declare module BABYLON {
  29411. /**
  29412. * @hidden
  29413. */
  29414. export class _IAnimationState {
  29415. key: number;
  29416. repeatCount: number;
  29417. workValue?: any;
  29418. loopMode?: number;
  29419. offsetValue?: any;
  29420. highLimitValue?: any;
  29421. }
  29422. /**
  29423. * Class used to store any kind of animation
  29424. */
  29425. export class Animation {
  29426. /**Name of the animation */
  29427. name: string;
  29428. /**Property to animate */
  29429. targetProperty: string;
  29430. /**The frames per second of the animation */
  29431. framePerSecond: number;
  29432. /**The data type of the animation */
  29433. dataType: number;
  29434. /**The loop mode of the animation */
  29435. loopMode?: number | undefined;
  29436. /**Specifies if blending should be enabled */
  29437. enableBlending?: boolean | undefined;
  29438. /**
  29439. * Use matrix interpolation instead of using direct key value when animating matrices
  29440. */
  29441. static AllowMatricesInterpolation: boolean;
  29442. /**
  29443. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29444. */
  29445. static AllowMatrixDecomposeForInterpolation: boolean;
  29446. /**
  29447. * Stores the key frames of the animation
  29448. */
  29449. private _keys;
  29450. /**
  29451. * Stores the easing function of the animation
  29452. */
  29453. private _easingFunction;
  29454. /**
  29455. * @hidden Internal use only
  29456. */
  29457. _runtimeAnimations: RuntimeAnimation[];
  29458. /**
  29459. * The set of event that will be linked to this animation
  29460. */
  29461. private _events;
  29462. /**
  29463. * Stores an array of target property paths
  29464. */
  29465. targetPropertyPath: string[];
  29466. /**
  29467. * Stores the blending speed of the animation
  29468. */
  29469. blendingSpeed: number;
  29470. /**
  29471. * Stores the animation ranges for the animation
  29472. */
  29473. private _ranges;
  29474. /**
  29475. * @hidden Internal use
  29476. */
  29477. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29478. /**
  29479. * Sets up an animation
  29480. * @param property The property to animate
  29481. * @param animationType The animation type to apply
  29482. * @param framePerSecond The frames per second of the animation
  29483. * @param easingFunction The easing function used in the animation
  29484. * @returns The created animation
  29485. */
  29486. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29487. /**
  29488. * Create and start an animation on a node
  29489. * @param name defines the name of the global animation that will be run on all nodes
  29490. * @param node defines the root node where the animation will take place
  29491. * @param targetProperty defines property to animate
  29492. * @param framePerSecond defines the number of frame per second yo use
  29493. * @param totalFrame defines the number of frames in total
  29494. * @param from defines the initial value
  29495. * @param to defines the final value
  29496. * @param loopMode defines which loop mode you want to use (off by default)
  29497. * @param easingFunction defines the easing function to use (linear by default)
  29498. * @param onAnimationEnd defines the callback to call when animation end
  29499. * @returns the animatable created for this animation
  29500. */
  29501. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29502. /**
  29503. * Create and start an animation on a node and its descendants
  29504. * @param name defines the name of the global animation that will be run on all nodes
  29505. * @param node defines the root node where the animation will take place
  29506. * @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
  29507. * @param targetProperty defines property to animate
  29508. * @param framePerSecond defines the number of frame per second to use
  29509. * @param totalFrame defines the number of frames in total
  29510. * @param from defines the initial value
  29511. * @param to defines the final value
  29512. * @param loopMode defines which loop mode you want to use (off by default)
  29513. * @param easingFunction defines the easing function to use (linear by default)
  29514. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29515. * @returns the list of animatables created for all nodes
  29516. * @example https://www.babylonjs-playground.com/#MH0VLI
  29517. */
  29518. 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[]>;
  29519. /**
  29520. * Creates a new animation, merges it with the existing animations and starts it
  29521. * @param name Name of the animation
  29522. * @param node Node which contains the scene that begins the animations
  29523. * @param targetProperty Specifies which property to animate
  29524. * @param framePerSecond The frames per second of the animation
  29525. * @param totalFrame The total number of frames
  29526. * @param from The frame at the beginning of the animation
  29527. * @param to The frame at the end of the animation
  29528. * @param loopMode Specifies the loop mode of the animation
  29529. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29530. * @param onAnimationEnd Callback to run once the animation is complete
  29531. * @returns Nullable animation
  29532. */
  29533. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29534. /**
  29535. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29536. * @param sourceAnimation defines the Animation containing keyframes to convert
  29537. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29538. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29539. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29540. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29541. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29542. */
  29543. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29544. /**
  29545. * Transition property of an host to the target Value
  29546. * @param property The property to transition
  29547. * @param targetValue The target Value of the property
  29548. * @param host The object where the property to animate belongs
  29549. * @param scene Scene used to run the animation
  29550. * @param frameRate Framerate (in frame/s) to use
  29551. * @param transition The transition type we want to use
  29552. * @param duration The duration of the animation, in milliseconds
  29553. * @param onAnimationEnd Callback trigger at the end of the animation
  29554. * @returns Nullable animation
  29555. */
  29556. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29557. /**
  29558. * Return the array of runtime animations currently using this animation
  29559. */
  29560. get runtimeAnimations(): RuntimeAnimation[];
  29561. /**
  29562. * Specifies if any of the runtime animations are currently running
  29563. */
  29564. get hasRunningRuntimeAnimations(): boolean;
  29565. /**
  29566. * Initializes the animation
  29567. * @param name Name of the animation
  29568. * @param targetProperty Property to animate
  29569. * @param framePerSecond The frames per second of the animation
  29570. * @param dataType The data type of the animation
  29571. * @param loopMode The loop mode of the animation
  29572. * @param enableBlending Specifies if blending should be enabled
  29573. */
  29574. constructor(
  29575. /**Name of the animation */
  29576. name: string,
  29577. /**Property to animate */
  29578. targetProperty: string,
  29579. /**The frames per second of the animation */
  29580. framePerSecond: number,
  29581. /**The data type of the animation */
  29582. dataType: number,
  29583. /**The loop mode of the animation */
  29584. loopMode?: number | undefined,
  29585. /**Specifies if blending should be enabled */
  29586. enableBlending?: boolean | undefined);
  29587. /**
  29588. * Converts the animation to a string
  29589. * @param fullDetails support for multiple levels of logging within scene loading
  29590. * @returns String form of the animation
  29591. */
  29592. toString(fullDetails?: boolean): string;
  29593. /**
  29594. * Add an event to this animation
  29595. * @param event Event to add
  29596. */
  29597. addEvent(event: AnimationEvent): void;
  29598. /**
  29599. * Remove all events found at the given frame
  29600. * @param frame The frame to remove events from
  29601. */
  29602. removeEvents(frame: number): void;
  29603. /**
  29604. * Retrieves all the events from the animation
  29605. * @returns Events from the animation
  29606. */
  29607. getEvents(): AnimationEvent[];
  29608. /**
  29609. * Creates an animation range
  29610. * @param name Name of the animation range
  29611. * @param from Starting frame of the animation range
  29612. * @param to Ending frame of the animation
  29613. */
  29614. createRange(name: string, from: number, to: number): void;
  29615. /**
  29616. * Deletes an animation range by name
  29617. * @param name Name of the animation range to delete
  29618. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29619. */
  29620. deleteRange(name: string, deleteFrames?: boolean): void;
  29621. /**
  29622. * Gets the animation range by name, or null if not defined
  29623. * @param name Name of the animation range
  29624. * @returns Nullable animation range
  29625. */
  29626. getRange(name: string): Nullable<AnimationRange>;
  29627. /**
  29628. * Gets the key frames from the animation
  29629. * @returns The key frames of the animation
  29630. */
  29631. getKeys(): Array<IAnimationKey>;
  29632. /**
  29633. * Gets the highest frame rate of the animation
  29634. * @returns Highest frame rate of the animation
  29635. */
  29636. getHighestFrame(): number;
  29637. /**
  29638. * Gets the easing function of the animation
  29639. * @returns Easing function of the animation
  29640. */
  29641. getEasingFunction(): IEasingFunction;
  29642. /**
  29643. * Sets the easing function of the animation
  29644. * @param easingFunction A custom mathematical formula for animation
  29645. */
  29646. setEasingFunction(easingFunction: EasingFunction): void;
  29647. /**
  29648. * Interpolates a scalar linearly
  29649. * @param startValue Start value of the animation curve
  29650. * @param endValue End value of the animation curve
  29651. * @param gradient Scalar amount to interpolate
  29652. * @returns Interpolated scalar value
  29653. */
  29654. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29655. /**
  29656. * Interpolates a scalar cubically
  29657. * @param startValue Start value of the animation curve
  29658. * @param outTangent End tangent of the animation
  29659. * @param endValue End value of the animation curve
  29660. * @param inTangent Start tangent of the animation curve
  29661. * @param gradient Scalar amount to interpolate
  29662. * @returns Interpolated scalar value
  29663. */
  29664. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29665. /**
  29666. * Interpolates a quaternion using a spherical linear interpolation
  29667. * @param startValue Start value of the animation curve
  29668. * @param endValue End value of the animation curve
  29669. * @param gradient Scalar amount to interpolate
  29670. * @returns Interpolated quaternion value
  29671. */
  29672. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29673. /**
  29674. * Interpolates a quaternion cubically
  29675. * @param startValue Start value of the animation curve
  29676. * @param outTangent End tangent of the animation curve
  29677. * @param endValue End value of the animation curve
  29678. * @param inTangent Start tangent of the animation curve
  29679. * @param gradient Scalar amount to interpolate
  29680. * @returns Interpolated quaternion value
  29681. */
  29682. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29683. /**
  29684. * Interpolates a Vector3 linearl
  29685. * @param startValue Start value of the animation curve
  29686. * @param endValue End value of the animation curve
  29687. * @param gradient Scalar amount to interpolate
  29688. * @returns Interpolated scalar value
  29689. */
  29690. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29691. /**
  29692. * Interpolates a Vector3 cubically
  29693. * @param startValue Start value of the animation curve
  29694. * @param outTangent End tangent of the animation
  29695. * @param endValue End value of the animation curve
  29696. * @param inTangent Start tangent of the animation curve
  29697. * @param gradient Scalar amount to interpolate
  29698. * @returns InterpolatedVector3 value
  29699. */
  29700. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29701. /**
  29702. * Interpolates a Vector2 linearly
  29703. * @param startValue Start value of the animation curve
  29704. * @param endValue End value of the animation curve
  29705. * @param gradient Scalar amount to interpolate
  29706. * @returns Interpolated Vector2 value
  29707. */
  29708. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29709. /**
  29710. * Interpolates a Vector2 cubically
  29711. * @param startValue Start value of the animation curve
  29712. * @param outTangent End tangent of the animation
  29713. * @param endValue End value of the animation curve
  29714. * @param inTangent Start tangent of the animation curve
  29715. * @param gradient Scalar amount to interpolate
  29716. * @returns Interpolated Vector2 value
  29717. */
  29718. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29719. /**
  29720. * Interpolates a size linearly
  29721. * @param startValue Start value of the animation curve
  29722. * @param endValue End value of the animation curve
  29723. * @param gradient Scalar amount to interpolate
  29724. * @returns Interpolated Size value
  29725. */
  29726. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29727. /**
  29728. * Interpolates a Color3 linearly
  29729. * @param startValue Start value of the animation curve
  29730. * @param endValue End value of the animation curve
  29731. * @param gradient Scalar amount to interpolate
  29732. * @returns Interpolated Color3 value
  29733. */
  29734. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29735. /**
  29736. * Interpolates a Color4 linearly
  29737. * @param startValue Start value of the animation curve
  29738. * @param endValue End value of the animation curve
  29739. * @param gradient Scalar amount to interpolate
  29740. * @returns Interpolated Color3 value
  29741. */
  29742. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29743. /**
  29744. * @hidden Internal use only
  29745. */
  29746. _getKeyValue(value: any): any;
  29747. /**
  29748. * @hidden Internal use only
  29749. */
  29750. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29751. /**
  29752. * Defines the function to use to interpolate matrices
  29753. * @param startValue defines the start matrix
  29754. * @param endValue defines the end matrix
  29755. * @param gradient defines the gradient between both matrices
  29756. * @param result defines an optional target matrix where to store the interpolation
  29757. * @returns the interpolated matrix
  29758. */
  29759. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29760. /**
  29761. * Makes a copy of the animation
  29762. * @returns Cloned animation
  29763. */
  29764. clone(): Animation;
  29765. /**
  29766. * Sets the key frames of the animation
  29767. * @param values The animation key frames to set
  29768. */
  29769. setKeys(values: Array<IAnimationKey>): void;
  29770. /**
  29771. * Serializes the animation to an object
  29772. * @returns Serialized object
  29773. */
  29774. serialize(): any;
  29775. /**
  29776. * Float animation type
  29777. */
  29778. static readonly ANIMATIONTYPE_FLOAT: number;
  29779. /**
  29780. * Vector3 animation type
  29781. */
  29782. static readonly ANIMATIONTYPE_VECTOR3: number;
  29783. /**
  29784. * Quaternion animation type
  29785. */
  29786. static readonly ANIMATIONTYPE_QUATERNION: number;
  29787. /**
  29788. * Matrix animation type
  29789. */
  29790. static readonly ANIMATIONTYPE_MATRIX: number;
  29791. /**
  29792. * Color3 animation type
  29793. */
  29794. static readonly ANIMATIONTYPE_COLOR3: number;
  29795. /**
  29796. * Color3 animation type
  29797. */
  29798. static readonly ANIMATIONTYPE_COLOR4: number;
  29799. /**
  29800. * Vector2 animation type
  29801. */
  29802. static readonly ANIMATIONTYPE_VECTOR2: number;
  29803. /**
  29804. * Size animation type
  29805. */
  29806. static readonly ANIMATIONTYPE_SIZE: number;
  29807. /**
  29808. * Relative Loop Mode
  29809. */
  29810. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29811. /**
  29812. * Cycle Loop Mode
  29813. */
  29814. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29815. /**
  29816. * Constant Loop Mode
  29817. */
  29818. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29819. /** @hidden */
  29820. static _UniversalLerp(left: any, right: any, amount: number): any;
  29821. /**
  29822. * Parses an animation object and creates an animation
  29823. * @param parsedAnimation Parsed animation object
  29824. * @returns Animation object
  29825. */
  29826. static Parse(parsedAnimation: any): Animation;
  29827. /**
  29828. * Appends the serialized animations from the source animations
  29829. * @param source Source containing the animations
  29830. * @param destination Target to store the animations
  29831. */
  29832. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29833. }
  29834. }
  29835. declare module BABYLON {
  29836. /**
  29837. * Interface containing an array of animations
  29838. */
  29839. export interface IAnimatable {
  29840. /**
  29841. * Array of animations
  29842. */
  29843. animations: Nullable<Array<Animation>>;
  29844. }
  29845. }
  29846. declare module BABYLON {
  29847. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29848. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29849. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29850. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29851. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29852. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29853. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29854. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29855. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29856. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29857. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29858. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29859. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29860. /**
  29861. * Decorator used to define property that can be serialized as reference to a camera
  29862. * @param sourceName defines the name of the property to decorate
  29863. */
  29864. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29865. /**
  29866. * Class used to help serialization objects
  29867. */
  29868. export class SerializationHelper {
  29869. /** @hidden */
  29870. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29871. /** @hidden */
  29872. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29873. /** @hidden */
  29874. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29875. /** @hidden */
  29876. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29877. /**
  29878. * Appends the serialized animations from the source animations
  29879. * @param source Source containing the animations
  29880. * @param destination Target to store the animations
  29881. */
  29882. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29883. /**
  29884. * Static function used to serialized a specific entity
  29885. * @param entity defines the entity to serialize
  29886. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29887. * @returns a JSON compatible object representing the serialization of the entity
  29888. */
  29889. static Serialize<T>(entity: T, serializationObject?: any): any;
  29890. /**
  29891. * Creates a new entity from a serialization data object
  29892. * @param creationFunction defines a function used to instanciated the new entity
  29893. * @param source defines the source serialization data
  29894. * @param scene defines the hosting scene
  29895. * @param rootUrl defines the root url for resources
  29896. * @returns a new entity
  29897. */
  29898. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29899. /**
  29900. * Clones an object
  29901. * @param creationFunction defines the function used to instanciate the new object
  29902. * @param source defines the source object
  29903. * @returns the cloned object
  29904. */
  29905. static Clone<T>(creationFunction: () => T, source: T): T;
  29906. /**
  29907. * Instanciates a new object based on a source one (some data will be shared between both object)
  29908. * @param creationFunction defines the function used to instanciate the new object
  29909. * @param source defines the source object
  29910. * @returns the new object
  29911. */
  29912. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29913. }
  29914. }
  29915. declare module BABYLON {
  29916. /**
  29917. * Class used to manipulate GUIDs
  29918. */
  29919. export class GUID {
  29920. /**
  29921. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29922. * Be aware Math.random() could cause collisions, but:
  29923. * "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"
  29924. * @returns a pseudo random id
  29925. */
  29926. static RandomId(): string;
  29927. }
  29928. }
  29929. declare module BABYLON {
  29930. /**
  29931. * Base class of all the textures in babylon.
  29932. * It groups all the common properties the materials, post process, lights... might need
  29933. * in order to make a correct use of the texture.
  29934. */
  29935. export class BaseTexture implements IAnimatable {
  29936. /**
  29937. * Default anisotropic filtering level for the application.
  29938. * It is set to 4 as a good tradeoff between perf and quality.
  29939. */
  29940. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29941. /**
  29942. * Gets or sets the unique id of the texture
  29943. */
  29944. uniqueId: number;
  29945. /**
  29946. * Define the name of the texture.
  29947. */
  29948. name: string;
  29949. /**
  29950. * Gets or sets an object used to store user defined information.
  29951. */
  29952. metadata: any;
  29953. /**
  29954. * For internal use only. Please do not use.
  29955. */
  29956. reservedDataStore: any;
  29957. private _hasAlpha;
  29958. /**
  29959. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29960. */
  29961. set hasAlpha(value: boolean);
  29962. get hasAlpha(): boolean;
  29963. /**
  29964. * Defines if the alpha value should be determined via the rgb values.
  29965. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29966. */
  29967. getAlphaFromRGB: boolean;
  29968. /**
  29969. * Intensity or strength of the texture.
  29970. * It is commonly used by materials to fine tune the intensity of the texture
  29971. */
  29972. level: number;
  29973. /**
  29974. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29975. * This is part of the texture as textures usually maps to one uv set.
  29976. */
  29977. coordinatesIndex: number;
  29978. private _coordinatesMode;
  29979. /**
  29980. * How a texture is mapped.
  29981. *
  29982. * | Value | Type | Description |
  29983. * | ----- | ----------------------------------- | ----------- |
  29984. * | 0 | EXPLICIT_MODE | |
  29985. * | 1 | SPHERICAL_MODE | |
  29986. * | 2 | PLANAR_MODE | |
  29987. * | 3 | CUBIC_MODE | |
  29988. * | 4 | PROJECTION_MODE | |
  29989. * | 5 | SKYBOX_MODE | |
  29990. * | 6 | INVCUBIC_MODE | |
  29991. * | 7 | EQUIRECTANGULAR_MODE | |
  29992. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29993. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29994. */
  29995. set coordinatesMode(value: number);
  29996. get coordinatesMode(): number;
  29997. /**
  29998. * | Value | Type | Description |
  29999. * | ----- | ------------------ | ----------- |
  30000. * | 0 | CLAMP_ADDRESSMODE | |
  30001. * | 1 | WRAP_ADDRESSMODE | |
  30002. * | 2 | MIRROR_ADDRESSMODE | |
  30003. */
  30004. wrapU: number;
  30005. /**
  30006. * | Value | Type | Description |
  30007. * | ----- | ------------------ | ----------- |
  30008. * | 0 | CLAMP_ADDRESSMODE | |
  30009. * | 1 | WRAP_ADDRESSMODE | |
  30010. * | 2 | MIRROR_ADDRESSMODE | |
  30011. */
  30012. wrapV: number;
  30013. /**
  30014. * | Value | Type | Description |
  30015. * | ----- | ------------------ | ----------- |
  30016. * | 0 | CLAMP_ADDRESSMODE | |
  30017. * | 1 | WRAP_ADDRESSMODE | |
  30018. * | 2 | MIRROR_ADDRESSMODE | |
  30019. */
  30020. wrapR: number;
  30021. /**
  30022. * With compliant hardware and browser (supporting anisotropic filtering)
  30023. * this defines the level of anisotropic filtering in the texture.
  30024. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30025. */
  30026. anisotropicFilteringLevel: number;
  30027. /**
  30028. * Define if the texture is a cube texture or if false a 2d texture.
  30029. */
  30030. get isCube(): boolean;
  30031. set isCube(value: boolean);
  30032. /**
  30033. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30034. */
  30035. get is3D(): boolean;
  30036. set is3D(value: boolean);
  30037. /**
  30038. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30039. */
  30040. get is2DArray(): boolean;
  30041. set is2DArray(value: boolean);
  30042. /**
  30043. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30044. * HDR texture are usually stored in linear space.
  30045. * This only impacts the PBR and Background materials
  30046. */
  30047. gammaSpace: boolean;
  30048. /**
  30049. * Gets or sets whether or not the texture contains RGBD data.
  30050. */
  30051. get isRGBD(): boolean;
  30052. set isRGBD(value: boolean);
  30053. /**
  30054. * Is Z inverted in the texture (useful in a cube texture).
  30055. */
  30056. invertZ: boolean;
  30057. /**
  30058. * Are mip maps generated for this texture or not.
  30059. */
  30060. get noMipmap(): boolean;
  30061. /**
  30062. * @hidden
  30063. */
  30064. lodLevelInAlpha: boolean;
  30065. /**
  30066. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30067. */
  30068. get lodGenerationOffset(): number;
  30069. set lodGenerationOffset(value: number);
  30070. /**
  30071. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30072. */
  30073. get lodGenerationScale(): number;
  30074. set lodGenerationScale(value: number);
  30075. /**
  30076. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30077. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30078. * average roughness values.
  30079. */
  30080. get linearSpecularLOD(): boolean;
  30081. set linearSpecularLOD(value: boolean);
  30082. /**
  30083. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30084. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30085. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30086. */
  30087. get irradianceTexture(): Nullable<BaseTexture>;
  30088. set irradianceTexture(value: Nullable<BaseTexture>);
  30089. /**
  30090. * Define if the texture is a render target.
  30091. */
  30092. isRenderTarget: boolean;
  30093. /**
  30094. * Define the unique id of the texture in the scene.
  30095. */
  30096. get uid(): string;
  30097. /**
  30098. * Return a string representation of the texture.
  30099. * @returns the texture as a string
  30100. */
  30101. toString(): string;
  30102. /**
  30103. * Get the class name of the texture.
  30104. * @returns "BaseTexture"
  30105. */
  30106. getClassName(): string;
  30107. /**
  30108. * Define the list of animation attached to the texture.
  30109. */
  30110. animations: Animation[];
  30111. /**
  30112. * An event triggered when the texture is disposed.
  30113. */
  30114. onDisposeObservable: Observable<BaseTexture>;
  30115. private _onDisposeObserver;
  30116. /**
  30117. * Callback triggered when the texture has been disposed.
  30118. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30119. */
  30120. set onDispose(callback: () => void);
  30121. /**
  30122. * Define the current state of the loading sequence when in delayed load mode.
  30123. */
  30124. delayLoadState: number;
  30125. private _scene;
  30126. /** @hidden */
  30127. _texture: Nullable<InternalTexture>;
  30128. private _uid;
  30129. /**
  30130. * Define if the texture is preventinga material to render or not.
  30131. * If not and the texture is not ready, the engine will use a default black texture instead.
  30132. */
  30133. get isBlocking(): boolean;
  30134. /**
  30135. * Instantiates a new BaseTexture.
  30136. * Base class of all the textures in babylon.
  30137. * It groups all the common properties the materials, post process, lights... might need
  30138. * in order to make a correct use of the texture.
  30139. * @param scene Define the scene the texture blongs to
  30140. */
  30141. constructor(scene: Nullable<Scene>);
  30142. /**
  30143. * Get the scene the texture belongs to.
  30144. * @returns the scene or null if undefined
  30145. */
  30146. getScene(): Nullable<Scene>;
  30147. /**
  30148. * Get the texture transform matrix used to offset tile the texture for istance.
  30149. * @returns the transformation matrix
  30150. */
  30151. getTextureMatrix(): Matrix;
  30152. /**
  30153. * Get the texture reflection matrix used to rotate/transform the reflection.
  30154. * @returns the reflection matrix
  30155. */
  30156. getReflectionTextureMatrix(): Matrix;
  30157. /**
  30158. * Get the underlying lower level texture from Babylon.
  30159. * @returns the insternal texture
  30160. */
  30161. getInternalTexture(): Nullable<InternalTexture>;
  30162. /**
  30163. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30164. * @returns true if ready or not blocking
  30165. */
  30166. isReadyOrNotBlocking(): boolean;
  30167. /**
  30168. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30169. * @returns true if fully ready
  30170. */
  30171. isReady(): boolean;
  30172. private _cachedSize;
  30173. /**
  30174. * Get the size of the texture.
  30175. * @returns the texture size.
  30176. */
  30177. getSize(): ISize;
  30178. /**
  30179. * Get the base size of the texture.
  30180. * It can be different from the size if the texture has been resized for POT for instance
  30181. * @returns the base size
  30182. */
  30183. getBaseSize(): ISize;
  30184. /**
  30185. * Update the sampling mode of the texture.
  30186. * Default is Trilinear mode.
  30187. *
  30188. * | Value | Type | Description |
  30189. * | ----- | ------------------ | ----------- |
  30190. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30191. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30192. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30193. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30194. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30195. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30196. * | 7 | NEAREST_LINEAR | |
  30197. * | 8 | NEAREST_NEAREST | |
  30198. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30199. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30200. * | 11 | LINEAR_LINEAR | |
  30201. * | 12 | LINEAR_NEAREST | |
  30202. *
  30203. * > _mag_: magnification filter (close to the viewer)
  30204. * > _min_: minification filter (far from the viewer)
  30205. * > _mip_: filter used between mip map levels
  30206. *@param samplingMode Define the new sampling mode of the texture
  30207. */
  30208. updateSamplingMode(samplingMode: number): void;
  30209. /**
  30210. * Scales the texture if is `canRescale()`
  30211. * @param ratio the resize factor we want to use to rescale
  30212. */
  30213. scale(ratio: number): void;
  30214. /**
  30215. * Get if the texture can rescale.
  30216. */
  30217. get canRescale(): boolean;
  30218. /** @hidden */
  30219. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30220. /** @hidden */
  30221. _rebuild(): void;
  30222. /**
  30223. * Triggers the load sequence in delayed load mode.
  30224. */
  30225. delayLoad(): void;
  30226. /**
  30227. * Clones the texture.
  30228. * @returns the cloned texture
  30229. */
  30230. clone(): Nullable<BaseTexture>;
  30231. /**
  30232. * Get the texture underlying type (INT, FLOAT...)
  30233. */
  30234. get textureType(): number;
  30235. /**
  30236. * Get the texture underlying format (RGB, RGBA...)
  30237. */
  30238. get textureFormat(): number;
  30239. /**
  30240. * Indicates that textures need to be re-calculated for all materials
  30241. */
  30242. protected _markAllSubMeshesAsTexturesDirty(): void;
  30243. /**
  30244. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30245. * This will returns an RGBA array buffer containing either in values (0-255) or
  30246. * float values (0-1) depending of the underlying buffer type.
  30247. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30248. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30249. * @param buffer defines a user defined buffer to fill with data (can be null)
  30250. * @returns The Array buffer containing the pixels data.
  30251. */
  30252. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30253. /**
  30254. * Release and destroy the underlying lower level texture aka internalTexture.
  30255. */
  30256. releaseInternalTexture(): void;
  30257. /** @hidden */
  30258. get _lodTextureHigh(): Nullable<BaseTexture>;
  30259. /** @hidden */
  30260. get _lodTextureMid(): Nullable<BaseTexture>;
  30261. /** @hidden */
  30262. get _lodTextureLow(): Nullable<BaseTexture>;
  30263. /**
  30264. * Dispose the texture and release its associated resources.
  30265. */
  30266. dispose(): void;
  30267. /**
  30268. * Serialize the texture into a JSON representation that can be parsed later on.
  30269. * @returns the JSON representation of the texture
  30270. */
  30271. serialize(): any;
  30272. /**
  30273. * Helper function to be called back once a list of texture contains only ready textures.
  30274. * @param textures Define the list of textures to wait for
  30275. * @param callback Define the callback triggered once the entire list will be ready
  30276. */
  30277. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30278. }
  30279. }
  30280. declare module BABYLON {
  30281. /**
  30282. * Options to be used when creating an effect.
  30283. */
  30284. export interface IEffectCreationOptions {
  30285. /**
  30286. * Atrributes that will be used in the shader.
  30287. */
  30288. attributes: string[];
  30289. /**
  30290. * Uniform varible names that will be set in the shader.
  30291. */
  30292. uniformsNames: string[];
  30293. /**
  30294. * Uniform buffer variable names that will be set in the shader.
  30295. */
  30296. uniformBuffersNames: string[];
  30297. /**
  30298. * Sampler texture variable names that will be set in the shader.
  30299. */
  30300. samplers: string[];
  30301. /**
  30302. * Define statements that will be set in the shader.
  30303. */
  30304. defines: any;
  30305. /**
  30306. * Possible fallbacks for this effect to improve performance when needed.
  30307. */
  30308. fallbacks: Nullable<IEffectFallbacks>;
  30309. /**
  30310. * Callback that will be called when the shader is compiled.
  30311. */
  30312. onCompiled: Nullable<(effect: Effect) => void>;
  30313. /**
  30314. * Callback that will be called if an error occurs during shader compilation.
  30315. */
  30316. onError: Nullable<(effect: Effect, errors: string) => void>;
  30317. /**
  30318. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30319. */
  30320. indexParameters?: any;
  30321. /**
  30322. * Max number of lights that can be used in the shader.
  30323. */
  30324. maxSimultaneousLights?: number;
  30325. /**
  30326. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30327. */
  30328. transformFeedbackVaryings?: Nullable<string[]>;
  30329. }
  30330. /**
  30331. * Effect containing vertex and fragment shader that can be executed on an object.
  30332. */
  30333. export class Effect implements IDisposable {
  30334. /**
  30335. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30336. */
  30337. static ShadersRepository: string;
  30338. /**
  30339. * Enable logging of the shader code when a compilation error occurs
  30340. */
  30341. static LogShaderCodeOnCompilationError: boolean;
  30342. /**
  30343. * Name of the effect.
  30344. */
  30345. name: any;
  30346. /**
  30347. * String container all the define statements that should be set on the shader.
  30348. */
  30349. defines: string;
  30350. /**
  30351. * Callback that will be called when the shader is compiled.
  30352. */
  30353. onCompiled: Nullable<(effect: Effect) => void>;
  30354. /**
  30355. * Callback that will be called if an error occurs during shader compilation.
  30356. */
  30357. onError: Nullable<(effect: Effect, errors: string) => void>;
  30358. /**
  30359. * Callback that will be called when effect is bound.
  30360. */
  30361. onBind: Nullable<(effect: Effect) => void>;
  30362. /**
  30363. * Unique ID of the effect.
  30364. */
  30365. uniqueId: number;
  30366. /**
  30367. * Observable that will be called when the shader is compiled.
  30368. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30369. */
  30370. onCompileObservable: Observable<Effect>;
  30371. /**
  30372. * Observable that will be called if an error occurs during shader compilation.
  30373. */
  30374. onErrorObservable: Observable<Effect>;
  30375. /** @hidden */
  30376. _onBindObservable: Nullable<Observable<Effect>>;
  30377. /**
  30378. * @hidden
  30379. * Specifies if the effect was previously ready
  30380. */
  30381. _wasPreviouslyReady: boolean;
  30382. /**
  30383. * Observable that will be called when effect is bound.
  30384. */
  30385. get onBindObservable(): Observable<Effect>;
  30386. /** @hidden */
  30387. _bonesComputationForcedToCPU: boolean;
  30388. private static _uniqueIdSeed;
  30389. private _engine;
  30390. private _uniformBuffersNames;
  30391. private _uniformsNames;
  30392. private _samplerList;
  30393. private _samplers;
  30394. private _isReady;
  30395. private _compilationError;
  30396. private _allFallbacksProcessed;
  30397. private _attributesNames;
  30398. private _attributes;
  30399. private _attributeLocationByName;
  30400. private _uniforms;
  30401. /**
  30402. * Key for the effect.
  30403. * @hidden
  30404. */
  30405. _key: string;
  30406. private _indexParameters;
  30407. private _fallbacks;
  30408. private _vertexSourceCode;
  30409. private _fragmentSourceCode;
  30410. private _vertexSourceCodeOverride;
  30411. private _fragmentSourceCodeOverride;
  30412. private _transformFeedbackVaryings;
  30413. /**
  30414. * Compiled shader to webGL program.
  30415. * @hidden
  30416. */
  30417. _pipelineContext: Nullable<IPipelineContext>;
  30418. private _valueCache;
  30419. private static _baseCache;
  30420. /**
  30421. * Instantiates an effect.
  30422. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30423. * @param baseName Name of the effect.
  30424. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30425. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30426. * @param samplers List of sampler variables that will be passed to the shader.
  30427. * @param engine Engine to be used to render the effect
  30428. * @param defines Define statements to be added to the shader.
  30429. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30430. * @param onCompiled Callback that will be called when the shader is compiled.
  30431. * @param onError Callback that will be called if an error occurs during shader compilation.
  30432. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30433. */
  30434. 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);
  30435. private _useFinalCode;
  30436. /**
  30437. * Unique key for this effect
  30438. */
  30439. get key(): string;
  30440. /**
  30441. * If the effect has been compiled and prepared.
  30442. * @returns if the effect is compiled and prepared.
  30443. */
  30444. isReady(): boolean;
  30445. private _isReadyInternal;
  30446. /**
  30447. * The engine the effect was initialized with.
  30448. * @returns the engine.
  30449. */
  30450. getEngine(): Engine;
  30451. /**
  30452. * The pipeline context for this effect
  30453. * @returns the associated pipeline context
  30454. */
  30455. getPipelineContext(): Nullable<IPipelineContext>;
  30456. /**
  30457. * The set of names of attribute variables for the shader.
  30458. * @returns An array of attribute names.
  30459. */
  30460. getAttributesNames(): string[];
  30461. /**
  30462. * Returns the attribute at the given index.
  30463. * @param index The index of the attribute.
  30464. * @returns The location of the attribute.
  30465. */
  30466. getAttributeLocation(index: number): number;
  30467. /**
  30468. * Returns the attribute based on the name of the variable.
  30469. * @param name of the attribute to look up.
  30470. * @returns the attribute location.
  30471. */
  30472. getAttributeLocationByName(name: string): number;
  30473. /**
  30474. * The number of attributes.
  30475. * @returns the numnber of attributes.
  30476. */
  30477. getAttributesCount(): number;
  30478. /**
  30479. * Gets the index of a uniform variable.
  30480. * @param uniformName of the uniform to look up.
  30481. * @returns the index.
  30482. */
  30483. getUniformIndex(uniformName: string): number;
  30484. /**
  30485. * Returns the attribute based on the name of the variable.
  30486. * @param uniformName of the uniform to look up.
  30487. * @returns the location of the uniform.
  30488. */
  30489. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30490. /**
  30491. * Returns an array of sampler variable names
  30492. * @returns The array of sampler variable neames.
  30493. */
  30494. getSamplers(): string[];
  30495. /**
  30496. * The error from the last compilation.
  30497. * @returns the error string.
  30498. */
  30499. getCompilationError(): string;
  30500. /**
  30501. * Gets a boolean indicating that all fallbacks were used during compilation
  30502. * @returns true if all fallbacks were used
  30503. */
  30504. allFallbacksProcessed(): boolean;
  30505. /**
  30506. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30507. * @param func The callback to be used.
  30508. */
  30509. executeWhenCompiled(func: (effect: Effect) => void): void;
  30510. private _checkIsReady;
  30511. private _loadShader;
  30512. /**
  30513. * Recompiles the webGL program
  30514. * @param vertexSourceCode The source code for the vertex shader.
  30515. * @param fragmentSourceCode The source code for the fragment shader.
  30516. * @param onCompiled Callback called when completed.
  30517. * @param onError Callback called on error.
  30518. * @hidden
  30519. */
  30520. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30521. /**
  30522. * Prepares the effect
  30523. * @hidden
  30524. */
  30525. _prepareEffect(): void;
  30526. private _getShaderCodeAndErrorLine;
  30527. private _processCompilationErrors;
  30528. /**
  30529. * Checks if the effect is supported. (Must be called after compilation)
  30530. */
  30531. get isSupported(): boolean;
  30532. /**
  30533. * Binds a texture to the engine to be used as output of the shader.
  30534. * @param channel Name of the output variable.
  30535. * @param texture Texture to bind.
  30536. * @hidden
  30537. */
  30538. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30539. /**
  30540. * Sets a texture on the engine to be used in the shader.
  30541. * @param channel Name of the sampler variable.
  30542. * @param texture Texture to set.
  30543. */
  30544. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30545. /**
  30546. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30547. * @param channel Name of the sampler variable.
  30548. * @param texture Texture to set.
  30549. */
  30550. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30551. /**
  30552. * Sets an array of textures on the engine to be used in the shader.
  30553. * @param channel Name of the variable.
  30554. * @param textures Textures to set.
  30555. */
  30556. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30557. /**
  30558. * 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)
  30559. * @param channel Name of the sampler variable.
  30560. * @param postProcess Post process to get the input texture from.
  30561. */
  30562. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30563. /**
  30564. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30565. * 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)
  30566. * @param channel Name of the sampler variable.
  30567. * @param postProcess Post process to get the output texture from.
  30568. */
  30569. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30570. /** @hidden */
  30571. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30572. /** @hidden */
  30573. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30574. /** @hidden */
  30575. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30576. /** @hidden */
  30577. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30578. /**
  30579. * Binds a buffer to a uniform.
  30580. * @param buffer Buffer to bind.
  30581. * @param name Name of the uniform variable to bind to.
  30582. */
  30583. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30584. /**
  30585. * Binds block to a uniform.
  30586. * @param blockName Name of the block to bind.
  30587. * @param index Index to bind.
  30588. */
  30589. bindUniformBlock(blockName: string, index: number): void;
  30590. /**
  30591. * Sets an interger value on a uniform variable.
  30592. * @param uniformName Name of the variable.
  30593. * @param value Value to be set.
  30594. * @returns this effect.
  30595. */
  30596. setInt(uniformName: string, value: number): Effect;
  30597. /**
  30598. * Sets an int array on a uniform variable.
  30599. * @param uniformName Name of the variable.
  30600. * @param array array to be set.
  30601. * @returns this effect.
  30602. */
  30603. setIntArray(uniformName: string, array: Int32Array): Effect;
  30604. /**
  30605. * 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)
  30606. * @param uniformName Name of the variable.
  30607. * @param array array to be set.
  30608. * @returns this effect.
  30609. */
  30610. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30611. /**
  30612. * 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)
  30613. * @param uniformName Name of the variable.
  30614. * @param array array to be set.
  30615. * @returns this effect.
  30616. */
  30617. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30618. /**
  30619. * 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)
  30620. * @param uniformName Name of the variable.
  30621. * @param array array to be set.
  30622. * @returns this effect.
  30623. */
  30624. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30625. /**
  30626. * Sets an float array on a uniform variable.
  30627. * @param uniformName Name of the variable.
  30628. * @param array array to be set.
  30629. * @returns this effect.
  30630. */
  30631. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30632. /**
  30633. * 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)
  30634. * @param uniformName Name of the variable.
  30635. * @param array array to be set.
  30636. * @returns this effect.
  30637. */
  30638. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30639. /**
  30640. * 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)
  30641. * @param uniformName Name of the variable.
  30642. * @param array array to be set.
  30643. * @returns this effect.
  30644. */
  30645. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30646. /**
  30647. * 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)
  30648. * @param uniformName Name of the variable.
  30649. * @param array array to be set.
  30650. * @returns this effect.
  30651. */
  30652. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30653. /**
  30654. * Sets an array on a uniform variable.
  30655. * @param uniformName Name of the variable.
  30656. * @param array array to be set.
  30657. * @returns this effect.
  30658. */
  30659. setArray(uniformName: string, array: number[]): Effect;
  30660. /**
  30661. * 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)
  30662. * @param uniformName Name of the variable.
  30663. * @param array array to be set.
  30664. * @returns this effect.
  30665. */
  30666. setArray2(uniformName: string, array: number[]): Effect;
  30667. /**
  30668. * 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)
  30669. * @param uniformName Name of the variable.
  30670. * @param array array to be set.
  30671. * @returns this effect.
  30672. */
  30673. setArray3(uniformName: string, array: number[]): Effect;
  30674. /**
  30675. * 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)
  30676. * @param uniformName Name of the variable.
  30677. * @param array array to be set.
  30678. * @returns this effect.
  30679. */
  30680. setArray4(uniformName: string, array: number[]): Effect;
  30681. /**
  30682. * Sets matrices on a uniform variable.
  30683. * @param uniformName Name of the variable.
  30684. * @param matrices matrices to be set.
  30685. * @returns this effect.
  30686. */
  30687. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30688. /**
  30689. * Sets matrix on a uniform variable.
  30690. * @param uniformName Name of the variable.
  30691. * @param matrix matrix to be set.
  30692. * @returns this effect.
  30693. */
  30694. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30695. /**
  30696. * 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)
  30697. * @param uniformName Name of the variable.
  30698. * @param matrix matrix to be set.
  30699. * @returns this effect.
  30700. */
  30701. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30702. /**
  30703. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30704. * @param uniformName Name of the variable.
  30705. * @param matrix matrix to be set.
  30706. * @returns this effect.
  30707. */
  30708. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30709. /**
  30710. * Sets a float on a uniform variable.
  30711. * @param uniformName Name of the variable.
  30712. * @param value value to be set.
  30713. * @returns this effect.
  30714. */
  30715. setFloat(uniformName: string, value: number): Effect;
  30716. /**
  30717. * Sets a boolean on a uniform variable.
  30718. * @param uniformName Name of the variable.
  30719. * @param bool value to be set.
  30720. * @returns this effect.
  30721. */
  30722. setBool(uniformName: string, bool: boolean): Effect;
  30723. /**
  30724. * Sets a Vector2 on a uniform variable.
  30725. * @param uniformName Name of the variable.
  30726. * @param vector2 vector2 to be set.
  30727. * @returns this effect.
  30728. */
  30729. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30730. /**
  30731. * Sets a float2 on a uniform variable.
  30732. * @param uniformName Name of the variable.
  30733. * @param x First float in float2.
  30734. * @param y Second float in float2.
  30735. * @returns this effect.
  30736. */
  30737. setFloat2(uniformName: string, x: number, y: number): Effect;
  30738. /**
  30739. * Sets a Vector3 on a uniform variable.
  30740. * @param uniformName Name of the variable.
  30741. * @param vector3 Value to be set.
  30742. * @returns this effect.
  30743. */
  30744. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30745. /**
  30746. * Sets a float3 on a uniform variable.
  30747. * @param uniformName Name of the variable.
  30748. * @param x First float in float3.
  30749. * @param y Second float in float3.
  30750. * @param z Third float in float3.
  30751. * @returns this effect.
  30752. */
  30753. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30754. /**
  30755. * Sets a Vector4 on a uniform variable.
  30756. * @param uniformName Name of the variable.
  30757. * @param vector4 Value to be set.
  30758. * @returns this effect.
  30759. */
  30760. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30761. /**
  30762. * Sets a float4 on a uniform variable.
  30763. * @param uniformName Name of the variable.
  30764. * @param x First float in float4.
  30765. * @param y Second float in float4.
  30766. * @param z Third float in float4.
  30767. * @param w Fourth float in float4.
  30768. * @returns this effect.
  30769. */
  30770. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30771. /**
  30772. * Sets a Color3 on a uniform variable.
  30773. * @param uniformName Name of the variable.
  30774. * @param color3 Value to be set.
  30775. * @returns this effect.
  30776. */
  30777. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30778. /**
  30779. * Sets a Color4 on a uniform variable.
  30780. * @param uniformName Name of the variable.
  30781. * @param color3 Value to be set.
  30782. * @param alpha Alpha value to be set.
  30783. * @returns this effect.
  30784. */
  30785. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30786. /**
  30787. * Sets a Color4 on a uniform variable
  30788. * @param uniformName defines the name of the variable
  30789. * @param color4 defines the value to be set
  30790. * @returns this effect.
  30791. */
  30792. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30793. /** Release all associated resources */
  30794. dispose(): void;
  30795. /**
  30796. * This function will add a new shader to the shader store
  30797. * @param name the name of the shader
  30798. * @param pixelShader optional pixel shader content
  30799. * @param vertexShader optional vertex shader content
  30800. */
  30801. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30802. /**
  30803. * Store of each shader (The can be looked up using effect.key)
  30804. */
  30805. static ShadersStore: {
  30806. [key: string]: string;
  30807. };
  30808. /**
  30809. * Store of each included file for a shader (The can be looked up using effect.key)
  30810. */
  30811. static IncludesShadersStore: {
  30812. [key: string]: string;
  30813. };
  30814. /**
  30815. * Resets the cache of effects.
  30816. */
  30817. static ResetCache(): void;
  30818. }
  30819. }
  30820. declare module BABYLON {
  30821. /**
  30822. * Interface used to describe the capabilities of the engine relatively to the current browser
  30823. */
  30824. export interface EngineCapabilities {
  30825. /** Maximum textures units per fragment shader */
  30826. maxTexturesImageUnits: number;
  30827. /** Maximum texture units per vertex shader */
  30828. maxVertexTextureImageUnits: number;
  30829. /** Maximum textures units in the entire pipeline */
  30830. maxCombinedTexturesImageUnits: number;
  30831. /** Maximum texture size */
  30832. maxTextureSize: number;
  30833. /** Maximum texture samples */
  30834. maxSamples?: number;
  30835. /** Maximum cube texture size */
  30836. maxCubemapTextureSize: number;
  30837. /** Maximum render texture size */
  30838. maxRenderTextureSize: number;
  30839. /** Maximum number of vertex attributes */
  30840. maxVertexAttribs: number;
  30841. /** Maximum number of varyings */
  30842. maxVaryingVectors: number;
  30843. /** Maximum number of uniforms per vertex shader */
  30844. maxVertexUniformVectors: number;
  30845. /** Maximum number of uniforms per fragment shader */
  30846. maxFragmentUniformVectors: number;
  30847. /** Defines if standard derivates (dx/dy) are supported */
  30848. standardDerivatives: boolean;
  30849. /** Defines if s3tc texture compression is supported */
  30850. s3tc?: WEBGL_compressed_texture_s3tc;
  30851. /** Defines if pvrtc texture compression is supported */
  30852. pvrtc: any;
  30853. /** Defines if etc1 texture compression is supported */
  30854. etc1: any;
  30855. /** Defines if etc2 texture compression is supported */
  30856. etc2: any;
  30857. /** Defines if astc texture compression is supported */
  30858. astc: any;
  30859. /** Defines if float textures are supported */
  30860. textureFloat: boolean;
  30861. /** Defines if vertex array objects are supported */
  30862. vertexArrayObject: boolean;
  30863. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30864. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30865. /** Gets the maximum level of anisotropy supported */
  30866. maxAnisotropy: number;
  30867. /** Defines if instancing is supported */
  30868. instancedArrays: boolean;
  30869. /** Defines if 32 bits indices are supported */
  30870. uintIndices: boolean;
  30871. /** Defines if high precision shaders are supported */
  30872. highPrecisionShaderSupported: boolean;
  30873. /** Defines if depth reading in the fragment shader is supported */
  30874. fragmentDepthSupported: boolean;
  30875. /** Defines if float texture linear filtering is supported*/
  30876. textureFloatLinearFiltering: boolean;
  30877. /** Defines if rendering to float textures is supported */
  30878. textureFloatRender: boolean;
  30879. /** Defines if half float textures are supported*/
  30880. textureHalfFloat: boolean;
  30881. /** Defines if half float texture linear filtering is supported*/
  30882. textureHalfFloatLinearFiltering: boolean;
  30883. /** Defines if rendering to half float textures is supported */
  30884. textureHalfFloatRender: boolean;
  30885. /** Defines if textureLOD shader command is supported */
  30886. textureLOD: boolean;
  30887. /** Defines if draw buffers extension is supported */
  30888. drawBuffersExtension: boolean;
  30889. /** Defines if depth textures are supported */
  30890. depthTextureExtension: boolean;
  30891. /** Defines if float color buffer are supported */
  30892. colorBufferFloat: boolean;
  30893. /** Gets disjoint timer query extension (null if not supported) */
  30894. timerQuery?: EXT_disjoint_timer_query;
  30895. /** Defines if timestamp can be used with timer query */
  30896. canUseTimestampForTimerQuery: boolean;
  30897. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30898. multiview?: any;
  30899. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30900. oculusMultiview?: any;
  30901. /** Function used to let the system compiles shaders in background */
  30902. parallelShaderCompile?: {
  30903. COMPLETION_STATUS_KHR: number;
  30904. };
  30905. /** Max number of texture samples for MSAA */
  30906. maxMSAASamples: number;
  30907. /** Defines if the blend min max extension is supported */
  30908. blendMinMax: boolean;
  30909. }
  30910. }
  30911. declare module BABYLON {
  30912. /**
  30913. * @hidden
  30914. **/
  30915. export class DepthCullingState {
  30916. private _isDepthTestDirty;
  30917. private _isDepthMaskDirty;
  30918. private _isDepthFuncDirty;
  30919. private _isCullFaceDirty;
  30920. private _isCullDirty;
  30921. private _isZOffsetDirty;
  30922. private _isFrontFaceDirty;
  30923. private _depthTest;
  30924. private _depthMask;
  30925. private _depthFunc;
  30926. private _cull;
  30927. private _cullFace;
  30928. private _zOffset;
  30929. private _frontFace;
  30930. /**
  30931. * Initializes the state.
  30932. */
  30933. constructor();
  30934. get isDirty(): boolean;
  30935. get zOffset(): number;
  30936. set zOffset(value: number);
  30937. get cullFace(): Nullable<number>;
  30938. set cullFace(value: Nullable<number>);
  30939. get cull(): Nullable<boolean>;
  30940. set cull(value: Nullable<boolean>);
  30941. get depthFunc(): Nullable<number>;
  30942. set depthFunc(value: Nullable<number>);
  30943. get depthMask(): boolean;
  30944. set depthMask(value: boolean);
  30945. get depthTest(): boolean;
  30946. set depthTest(value: boolean);
  30947. get frontFace(): Nullable<number>;
  30948. set frontFace(value: Nullable<number>);
  30949. reset(): void;
  30950. apply(gl: WebGLRenderingContext): void;
  30951. }
  30952. }
  30953. declare module BABYLON {
  30954. /**
  30955. * @hidden
  30956. **/
  30957. export class StencilState {
  30958. /** 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 */
  30959. static readonly ALWAYS: number;
  30960. /** Passed to stencilOperation to specify that stencil value must be kept */
  30961. static readonly KEEP: number;
  30962. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30963. static readonly REPLACE: number;
  30964. private _isStencilTestDirty;
  30965. private _isStencilMaskDirty;
  30966. private _isStencilFuncDirty;
  30967. private _isStencilOpDirty;
  30968. private _stencilTest;
  30969. private _stencilMask;
  30970. private _stencilFunc;
  30971. private _stencilFuncRef;
  30972. private _stencilFuncMask;
  30973. private _stencilOpStencilFail;
  30974. private _stencilOpDepthFail;
  30975. private _stencilOpStencilDepthPass;
  30976. get isDirty(): boolean;
  30977. get stencilFunc(): number;
  30978. set stencilFunc(value: number);
  30979. get stencilFuncRef(): number;
  30980. set stencilFuncRef(value: number);
  30981. get stencilFuncMask(): number;
  30982. set stencilFuncMask(value: number);
  30983. get stencilOpStencilFail(): number;
  30984. set stencilOpStencilFail(value: number);
  30985. get stencilOpDepthFail(): number;
  30986. set stencilOpDepthFail(value: number);
  30987. get stencilOpStencilDepthPass(): number;
  30988. set stencilOpStencilDepthPass(value: number);
  30989. get stencilMask(): number;
  30990. set stencilMask(value: number);
  30991. get stencilTest(): boolean;
  30992. set stencilTest(value: boolean);
  30993. constructor();
  30994. reset(): void;
  30995. apply(gl: WebGLRenderingContext): void;
  30996. }
  30997. }
  30998. declare module BABYLON {
  30999. /**
  31000. * @hidden
  31001. **/
  31002. export class AlphaState {
  31003. private _isAlphaBlendDirty;
  31004. private _isBlendFunctionParametersDirty;
  31005. private _isBlendEquationParametersDirty;
  31006. private _isBlendConstantsDirty;
  31007. private _alphaBlend;
  31008. private _blendFunctionParameters;
  31009. private _blendEquationParameters;
  31010. private _blendConstants;
  31011. /**
  31012. * Initializes the state.
  31013. */
  31014. constructor();
  31015. get isDirty(): boolean;
  31016. get alphaBlend(): boolean;
  31017. set alphaBlend(value: boolean);
  31018. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31019. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31020. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31021. reset(): void;
  31022. apply(gl: WebGLRenderingContext): void;
  31023. }
  31024. }
  31025. declare module BABYLON {
  31026. /** @hidden */
  31027. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31028. attributeProcessor(attribute: string): string;
  31029. varyingProcessor(varying: string, isFragment: boolean): string;
  31030. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31031. }
  31032. }
  31033. declare module BABYLON {
  31034. /**
  31035. * Interface for attribute information associated with buffer instanciation
  31036. */
  31037. export interface InstancingAttributeInfo {
  31038. /**
  31039. * Name of the GLSL attribute
  31040. * if attribute index is not specified, this is used to retrieve the index from the effect
  31041. */
  31042. attributeName: string;
  31043. /**
  31044. * Index/offset of the attribute in the vertex shader
  31045. * if not specified, this will be computes from the name.
  31046. */
  31047. index?: number;
  31048. /**
  31049. * size of the attribute, 1, 2, 3 or 4
  31050. */
  31051. attributeSize: number;
  31052. /**
  31053. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31054. */
  31055. offset: number;
  31056. /**
  31057. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31058. * default to 1
  31059. */
  31060. divisor?: number;
  31061. /**
  31062. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31063. * default is FLOAT
  31064. */
  31065. attributeType?: number;
  31066. /**
  31067. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31068. */
  31069. normalized?: boolean;
  31070. }
  31071. }
  31072. declare module BABYLON {
  31073. interface ThinEngine {
  31074. /**
  31075. * Update a video texture
  31076. * @param texture defines the texture to update
  31077. * @param video defines the video element to use
  31078. * @param invertY defines if data must be stored with Y axis inverted
  31079. */
  31080. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31081. }
  31082. }
  31083. declare module BABYLON {
  31084. /**
  31085. * Settings for finer control over video usage
  31086. */
  31087. export interface VideoTextureSettings {
  31088. /**
  31089. * Applies `autoplay` to video, if specified
  31090. */
  31091. autoPlay?: boolean;
  31092. /**
  31093. * Applies `loop` to video, if specified
  31094. */
  31095. loop?: boolean;
  31096. /**
  31097. * Automatically updates internal texture from video at every frame in the render loop
  31098. */
  31099. autoUpdateTexture: boolean;
  31100. /**
  31101. * Image src displayed during the video loading or until the user interacts with the video.
  31102. */
  31103. poster?: string;
  31104. }
  31105. /**
  31106. * If you want to display a video in your scene, this is the special texture for that.
  31107. * This special texture works similar to other textures, with the exception of a few parameters.
  31108. * @see https://doc.babylonjs.com/how_to/video_texture
  31109. */
  31110. export class VideoTexture extends Texture {
  31111. /**
  31112. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31113. */
  31114. readonly autoUpdateTexture: boolean;
  31115. /**
  31116. * The video instance used by the texture internally
  31117. */
  31118. readonly video: HTMLVideoElement;
  31119. private _onUserActionRequestedObservable;
  31120. /**
  31121. * Event triggerd when a dom action is required by the user to play the video.
  31122. * This happens due to recent changes in browser policies preventing video to auto start.
  31123. */
  31124. get onUserActionRequestedObservable(): Observable<Texture>;
  31125. private _generateMipMaps;
  31126. private _engine;
  31127. private _stillImageCaptured;
  31128. private _displayingPosterTexture;
  31129. private _settings;
  31130. private _createInternalTextureOnEvent;
  31131. private _frameId;
  31132. private _currentSrc;
  31133. /**
  31134. * Creates a video texture.
  31135. * If you want to display a video in your scene, this is the special texture for that.
  31136. * This special texture works similar to other textures, with the exception of a few parameters.
  31137. * @see https://doc.babylonjs.com/how_to/video_texture
  31138. * @param name optional name, will detect from video source, if not defined
  31139. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31140. * @param scene is obviously the current scene.
  31141. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31142. * @param invertY is false by default but can be used to invert video on Y axis
  31143. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31144. * @param settings allows finer control over video usage
  31145. */
  31146. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31147. private _getName;
  31148. private _getVideo;
  31149. private _createInternalTexture;
  31150. private reset;
  31151. /**
  31152. * @hidden Internal method to initiate `update`.
  31153. */
  31154. _rebuild(): void;
  31155. /**
  31156. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31157. */
  31158. update(): void;
  31159. /**
  31160. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31161. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31162. */
  31163. updateTexture(isVisible: boolean): void;
  31164. protected _updateInternalTexture: () => void;
  31165. /**
  31166. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31167. * @param url New url.
  31168. */
  31169. updateURL(url: string): void;
  31170. /**
  31171. * Clones the texture.
  31172. * @returns the cloned texture
  31173. */
  31174. clone(): VideoTexture;
  31175. /**
  31176. * Dispose the texture and release its associated resources.
  31177. */
  31178. dispose(): void;
  31179. /**
  31180. * Creates a video texture straight from a stream.
  31181. * @param scene Define the scene the texture should be created in
  31182. * @param stream Define the stream the texture should be created from
  31183. * @returns The created video texture as a promise
  31184. */
  31185. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31186. /**
  31187. * Creates a video texture straight from your WebCam video feed.
  31188. * @param scene Define the scene the texture should be created in
  31189. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31190. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31191. * @returns The created video texture as a promise
  31192. */
  31193. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31194. minWidth: number;
  31195. maxWidth: number;
  31196. minHeight: number;
  31197. maxHeight: number;
  31198. deviceId: string;
  31199. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31200. /**
  31201. * Creates a video texture straight from your WebCam video feed.
  31202. * @param scene Define the scene the texture should be created in
  31203. * @param onReady Define a callback to triggered once the texture will be ready
  31204. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31205. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31206. */
  31207. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31208. minWidth: number;
  31209. maxWidth: number;
  31210. minHeight: number;
  31211. maxHeight: number;
  31212. deviceId: string;
  31213. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31214. }
  31215. }
  31216. declare module BABYLON {
  31217. /**
  31218. * Defines the interface used by objects working like Scene
  31219. * @hidden
  31220. */
  31221. export interface ISceneLike {
  31222. _addPendingData(data: any): void;
  31223. _removePendingData(data: any): void;
  31224. offlineProvider: IOfflineProvider;
  31225. }
  31226. /** Interface defining initialization parameters for Engine class */
  31227. export interface EngineOptions extends WebGLContextAttributes {
  31228. /**
  31229. * Defines if the engine should no exceed a specified device ratio
  31230. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31231. */
  31232. limitDeviceRatio?: number;
  31233. /**
  31234. * Defines if webvr should be enabled automatically
  31235. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31236. */
  31237. autoEnableWebVR?: boolean;
  31238. /**
  31239. * Defines if webgl2 should be turned off even if supported
  31240. * @see http://doc.babylonjs.com/features/webgl2
  31241. */
  31242. disableWebGL2Support?: boolean;
  31243. /**
  31244. * Defines if webaudio should be initialized as well
  31245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31246. */
  31247. audioEngine?: boolean;
  31248. /**
  31249. * Defines if animations should run using a deterministic lock step
  31250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31251. */
  31252. deterministicLockstep?: boolean;
  31253. /** Defines the maximum steps to use with deterministic lock step mode */
  31254. lockstepMaxSteps?: number;
  31255. /** Defines the seconds between each deterministic lock step */
  31256. timeStep?: number;
  31257. /**
  31258. * Defines that engine should ignore context lost events
  31259. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31260. */
  31261. doNotHandleContextLost?: boolean;
  31262. /**
  31263. * Defines that engine should ignore modifying touch action attribute and style
  31264. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31265. */
  31266. doNotHandleTouchAction?: boolean;
  31267. /**
  31268. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31269. */
  31270. useHighPrecisionFloats?: boolean;
  31271. }
  31272. /**
  31273. * The base engine class (root of all engines)
  31274. */
  31275. export class ThinEngine {
  31276. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31277. static ExceptionList: ({
  31278. key: string;
  31279. capture: string;
  31280. captureConstraint: number;
  31281. targets: string[];
  31282. } | {
  31283. key: string;
  31284. capture: null;
  31285. captureConstraint: null;
  31286. targets: string[];
  31287. })[];
  31288. /** @hidden */
  31289. static _TextureLoaders: IInternalTextureLoader[];
  31290. /**
  31291. * Returns the current npm package of the sdk
  31292. */
  31293. static get NpmPackage(): string;
  31294. /**
  31295. * Returns the current version of the framework
  31296. */
  31297. static get Version(): string;
  31298. /**
  31299. * Returns a string describing the current engine
  31300. */
  31301. get description(): string;
  31302. /**
  31303. * Gets or sets the epsilon value used by collision engine
  31304. */
  31305. static CollisionsEpsilon: number;
  31306. /**
  31307. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31308. */
  31309. static get ShadersRepository(): string;
  31310. static set ShadersRepository(value: string);
  31311. /** @hidden */
  31312. _shaderProcessor: IShaderProcessor;
  31313. /**
  31314. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31315. */
  31316. forcePOTTextures: boolean;
  31317. /**
  31318. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31319. */
  31320. isFullscreen: boolean;
  31321. /**
  31322. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31323. */
  31324. cullBackFaces: boolean;
  31325. /**
  31326. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31327. */
  31328. renderEvenInBackground: boolean;
  31329. /**
  31330. * Gets or sets a boolean indicating that cache can be kept between frames
  31331. */
  31332. preventCacheWipeBetweenFrames: boolean;
  31333. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31334. validateShaderPrograms: boolean;
  31335. /**
  31336. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31337. * This can provide greater z depth for distant objects.
  31338. */
  31339. useReverseDepthBuffer: boolean;
  31340. /**
  31341. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31342. */
  31343. disableUniformBuffers: boolean;
  31344. /** @hidden */
  31345. _uniformBuffers: UniformBuffer[];
  31346. /**
  31347. * Gets a boolean indicating that the engine supports uniform buffers
  31348. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31349. */
  31350. get supportsUniformBuffers(): boolean;
  31351. /** @hidden */
  31352. _gl: WebGLRenderingContext;
  31353. /** @hidden */
  31354. _webGLVersion: number;
  31355. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31356. protected _windowIsBackground: boolean;
  31357. protected _creationOptions: EngineOptions;
  31358. protected _highPrecisionShadersAllowed: boolean;
  31359. /** @hidden */
  31360. get _shouldUseHighPrecisionShader(): boolean;
  31361. /**
  31362. * Gets a boolean indicating that only power of 2 textures are supported
  31363. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31364. */
  31365. get needPOTTextures(): boolean;
  31366. /** @hidden */
  31367. _badOS: boolean;
  31368. /** @hidden */
  31369. _badDesktopOS: boolean;
  31370. private _hardwareScalingLevel;
  31371. /** @hidden */
  31372. _caps: EngineCapabilities;
  31373. private _isStencilEnable;
  31374. private _glVersion;
  31375. private _glRenderer;
  31376. private _glVendor;
  31377. /** @hidden */
  31378. _videoTextureSupported: boolean;
  31379. protected _renderingQueueLaunched: boolean;
  31380. protected _activeRenderLoops: (() => void)[];
  31381. /**
  31382. * Observable signaled when a context lost event is raised
  31383. */
  31384. onContextLostObservable: Observable<ThinEngine>;
  31385. /**
  31386. * Observable signaled when a context restored event is raised
  31387. */
  31388. onContextRestoredObservable: Observable<ThinEngine>;
  31389. private _onContextLost;
  31390. private _onContextRestored;
  31391. protected _contextWasLost: boolean;
  31392. /** @hidden */
  31393. _doNotHandleContextLost: boolean;
  31394. /**
  31395. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31397. */
  31398. get doNotHandleContextLost(): boolean;
  31399. set doNotHandleContextLost(value: boolean);
  31400. /**
  31401. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31402. */
  31403. disableVertexArrayObjects: boolean;
  31404. /** @hidden */
  31405. protected _colorWrite: boolean;
  31406. /** @hidden */
  31407. protected _colorWriteChanged: boolean;
  31408. /** @hidden */
  31409. protected _depthCullingState: DepthCullingState;
  31410. /** @hidden */
  31411. protected _stencilState: StencilState;
  31412. /** @hidden */
  31413. _alphaState: AlphaState;
  31414. /** @hidden */
  31415. _alphaMode: number;
  31416. /** @hidden */
  31417. _alphaEquation: number;
  31418. /** @hidden */
  31419. _internalTexturesCache: InternalTexture[];
  31420. /** @hidden */
  31421. protected _activeChannel: number;
  31422. private _currentTextureChannel;
  31423. /** @hidden */
  31424. protected _boundTexturesCache: {
  31425. [key: string]: Nullable<InternalTexture>;
  31426. };
  31427. /** @hidden */
  31428. protected _currentEffect: Nullable<Effect>;
  31429. /** @hidden */
  31430. protected _currentProgram: Nullable<WebGLProgram>;
  31431. private _compiledEffects;
  31432. private _vertexAttribArraysEnabled;
  31433. /** @hidden */
  31434. protected _cachedViewport: Nullable<IViewportLike>;
  31435. private _cachedVertexArrayObject;
  31436. /** @hidden */
  31437. protected _cachedVertexBuffers: any;
  31438. /** @hidden */
  31439. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31440. /** @hidden */
  31441. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31442. /** @hidden */
  31443. _currentRenderTarget: Nullable<InternalTexture>;
  31444. private _uintIndicesCurrentlySet;
  31445. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31446. /** @hidden */
  31447. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31448. private _currentBufferPointers;
  31449. private _currentInstanceLocations;
  31450. private _currentInstanceBuffers;
  31451. private _textureUnits;
  31452. /** @hidden */
  31453. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31454. /** @hidden */
  31455. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31456. /** @hidden */
  31457. _boundRenderFunction: any;
  31458. private _vaoRecordInProgress;
  31459. private _mustWipeVertexAttributes;
  31460. private _emptyTexture;
  31461. private _emptyCubeTexture;
  31462. private _emptyTexture3D;
  31463. private _emptyTexture2DArray;
  31464. /** @hidden */
  31465. _frameHandler: number;
  31466. private _nextFreeTextureSlots;
  31467. private _maxSimultaneousTextures;
  31468. private _activeRequests;
  31469. /** @hidden */
  31470. _transformTextureUrl: Nullable<(url: string) => string>;
  31471. protected get _supportsHardwareTextureRescaling(): boolean;
  31472. private _framebufferDimensionsObject;
  31473. /**
  31474. * sets the object from which width and height will be taken from when getting render width and height
  31475. * Will fallback to the gl object
  31476. * @param dimensions the framebuffer width and height that will be used.
  31477. */
  31478. set framebufferDimensionsObject(dimensions: Nullable<{
  31479. framebufferWidth: number;
  31480. framebufferHeight: number;
  31481. }>);
  31482. /**
  31483. * Gets the current viewport
  31484. */
  31485. get currentViewport(): Nullable<IViewportLike>;
  31486. /**
  31487. * Gets the default empty texture
  31488. */
  31489. get emptyTexture(): InternalTexture;
  31490. /**
  31491. * Gets the default empty 3D texture
  31492. */
  31493. get emptyTexture3D(): InternalTexture;
  31494. /**
  31495. * Gets the default empty 2D array texture
  31496. */
  31497. get emptyTexture2DArray(): InternalTexture;
  31498. /**
  31499. * Gets the default empty cube texture
  31500. */
  31501. get emptyCubeTexture(): InternalTexture;
  31502. /**
  31503. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31504. */
  31505. readonly premultipliedAlpha: boolean;
  31506. /**
  31507. * Observable event triggered before each texture is initialized
  31508. */
  31509. onBeforeTextureInitObservable: Observable<Texture>;
  31510. /**
  31511. * Creates a new engine
  31512. * @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
  31513. * @param antialias defines enable antialiasing (default: false)
  31514. * @param options defines further options to be sent to the getContext() function
  31515. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31516. */
  31517. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31518. private _rebuildInternalTextures;
  31519. private _rebuildEffects;
  31520. /**
  31521. * Gets a boolean indicating if all created effects are ready
  31522. * @returns true if all effects are ready
  31523. */
  31524. areAllEffectsReady(): boolean;
  31525. protected _rebuildBuffers(): void;
  31526. protected _initGLContext(): void;
  31527. /**
  31528. * Gets version of the current webGL context
  31529. */
  31530. get webGLVersion(): number;
  31531. /**
  31532. * Gets a string idenfifying the name of the class
  31533. * @returns "Engine" string
  31534. */
  31535. getClassName(): string;
  31536. /**
  31537. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31538. */
  31539. get isStencilEnable(): boolean;
  31540. /** @hidden */
  31541. _prepareWorkingCanvas(): void;
  31542. /**
  31543. * Reset the texture cache to empty state
  31544. */
  31545. resetTextureCache(): void;
  31546. /**
  31547. * Gets an object containing information about the current webGL context
  31548. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31549. */
  31550. getGlInfo(): {
  31551. vendor: string;
  31552. renderer: string;
  31553. version: string;
  31554. };
  31555. /**
  31556. * Defines the hardware scaling level.
  31557. * By default the hardware scaling level is computed from the window device ratio.
  31558. * 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.
  31559. * @param level defines the level to use
  31560. */
  31561. setHardwareScalingLevel(level: number): void;
  31562. /**
  31563. * Gets the current hardware scaling level.
  31564. * By default the hardware scaling level is computed from the window device ratio.
  31565. * 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.
  31566. * @returns a number indicating the current hardware scaling level
  31567. */
  31568. getHardwareScalingLevel(): number;
  31569. /**
  31570. * Gets the list of loaded textures
  31571. * @returns an array containing all loaded textures
  31572. */
  31573. getLoadedTexturesCache(): InternalTexture[];
  31574. /**
  31575. * Gets the object containing all engine capabilities
  31576. * @returns the EngineCapabilities object
  31577. */
  31578. getCaps(): EngineCapabilities;
  31579. /**
  31580. * stop executing a render loop function and remove it from the execution array
  31581. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31582. */
  31583. stopRenderLoop(renderFunction?: () => void): void;
  31584. /** @hidden */
  31585. _renderLoop(): void;
  31586. /**
  31587. * Gets the HTML canvas attached with the current webGL context
  31588. * @returns a HTML canvas
  31589. */
  31590. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31591. /**
  31592. * Gets host window
  31593. * @returns the host window object
  31594. */
  31595. getHostWindow(): Nullable<Window>;
  31596. /**
  31597. * Gets the current render width
  31598. * @param useScreen defines if screen size must be used (or the current render target if any)
  31599. * @returns a number defining the current render width
  31600. */
  31601. getRenderWidth(useScreen?: boolean): number;
  31602. /**
  31603. * Gets the current render height
  31604. * @param useScreen defines if screen size must be used (or the current render target if any)
  31605. * @returns a number defining the current render height
  31606. */
  31607. getRenderHeight(useScreen?: boolean): number;
  31608. /**
  31609. * Can be used to override the current requestAnimationFrame requester.
  31610. * @hidden
  31611. */
  31612. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31613. /**
  31614. * Register and execute a render loop. The engine can have more than one render function
  31615. * @param renderFunction defines the function to continuously execute
  31616. */
  31617. runRenderLoop(renderFunction: () => void): void;
  31618. /**
  31619. * Clear the current render buffer or the current render target (if any is set up)
  31620. * @param color defines the color to use
  31621. * @param backBuffer defines if the back buffer must be cleared
  31622. * @param depth defines if the depth buffer must be cleared
  31623. * @param stencil defines if the stencil buffer must be cleared
  31624. */
  31625. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31626. private _viewportCached;
  31627. /** @hidden */
  31628. _viewport(x: number, y: number, width: number, height: number): void;
  31629. /**
  31630. * Set the WebGL's viewport
  31631. * @param viewport defines the viewport element to be used
  31632. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31633. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31634. */
  31635. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31636. /**
  31637. * Begin a new frame
  31638. */
  31639. beginFrame(): void;
  31640. /**
  31641. * Enf the current frame
  31642. */
  31643. endFrame(): void;
  31644. /**
  31645. * Resize the view according to the canvas' size
  31646. */
  31647. resize(): void;
  31648. /**
  31649. * Force a specific size of the canvas
  31650. * @param width defines the new canvas' width
  31651. * @param height defines the new canvas' height
  31652. */
  31653. setSize(width: number, height: number): void;
  31654. /**
  31655. * Binds the frame buffer to the specified texture.
  31656. * @param texture The texture to render to or null for the default canvas
  31657. * @param faceIndex The face of the texture to render to in case of cube texture
  31658. * @param requiredWidth The width of the target to render to
  31659. * @param requiredHeight The height of the target to render to
  31660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31661. * @param lodLevel defines the lod level to bind to the frame buffer
  31662. * @param layer defines the 2d array index to bind to frame buffer to
  31663. */
  31664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31665. /** @hidden */
  31666. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31667. /**
  31668. * Unbind the current render target texture from the webGL context
  31669. * @param texture defines the render target texture to unbind
  31670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31672. */
  31673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31674. /**
  31675. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31676. */
  31677. flushFramebuffer(): void;
  31678. /**
  31679. * Unbind the current render target and bind the default framebuffer
  31680. */
  31681. restoreDefaultFramebuffer(): void;
  31682. /** @hidden */
  31683. protected _resetVertexBufferBinding(): void;
  31684. /**
  31685. * Creates a vertex buffer
  31686. * @param data the data for the vertex buffer
  31687. * @returns the new WebGL static buffer
  31688. */
  31689. createVertexBuffer(data: DataArray): DataBuffer;
  31690. private _createVertexBuffer;
  31691. /**
  31692. * Creates a dynamic vertex buffer
  31693. * @param data the data for the dynamic vertex buffer
  31694. * @returns the new WebGL dynamic buffer
  31695. */
  31696. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31697. protected _resetIndexBufferBinding(): void;
  31698. /**
  31699. * Creates a new index buffer
  31700. * @param indices defines the content of the index buffer
  31701. * @param updatable defines if the index buffer must be updatable
  31702. * @returns a new webGL buffer
  31703. */
  31704. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31705. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31706. /**
  31707. * Bind a webGL buffer to the webGL context
  31708. * @param buffer defines the buffer to bind
  31709. */
  31710. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31711. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31712. private bindBuffer;
  31713. /**
  31714. * update the bound buffer with the given data
  31715. * @param data defines the data to update
  31716. */
  31717. updateArrayBuffer(data: Float32Array): void;
  31718. private _vertexAttribPointer;
  31719. /** @hidden */
  31720. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31721. private _bindVertexBuffersAttributes;
  31722. /**
  31723. * Records a vertex array object
  31724. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31725. * @param vertexBuffers defines the list of vertex buffers to store
  31726. * @param indexBuffer defines the index buffer to store
  31727. * @param effect defines the effect to store
  31728. * @returns the new vertex array object
  31729. */
  31730. recordVertexArrayObject(vertexBuffers: {
  31731. [key: string]: VertexBuffer;
  31732. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31733. /**
  31734. * Bind a specific vertex array object
  31735. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31736. * @param vertexArrayObject defines the vertex array object to bind
  31737. * @param indexBuffer defines the index buffer to bind
  31738. */
  31739. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31740. /**
  31741. * Bind webGl buffers directly to the webGL context
  31742. * @param vertexBuffer defines the vertex buffer to bind
  31743. * @param indexBuffer defines the index buffer to bind
  31744. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31745. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31746. * @param effect defines the effect associated with the vertex buffer
  31747. */
  31748. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31749. private _unbindVertexArrayObject;
  31750. /**
  31751. * Bind a list of vertex buffers to the webGL context
  31752. * @param vertexBuffers defines the list of vertex buffers to bind
  31753. * @param indexBuffer defines the index buffer to bind
  31754. * @param effect defines the effect associated with the vertex buffers
  31755. */
  31756. bindBuffers(vertexBuffers: {
  31757. [key: string]: Nullable<VertexBuffer>;
  31758. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31759. /**
  31760. * Unbind all instance attributes
  31761. */
  31762. unbindInstanceAttributes(): void;
  31763. /**
  31764. * Release and free the memory of a vertex array object
  31765. * @param vao defines the vertex array object to delete
  31766. */
  31767. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31768. /** @hidden */
  31769. _releaseBuffer(buffer: DataBuffer): boolean;
  31770. protected _deleteBuffer(buffer: DataBuffer): void;
  31771. /**
  31772. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31773. * @param instancesBuffer defines the webGL buffer to update and bind
  31774. * @param data defines the data to store in the buffer
  31775. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31776. */
  31777. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31778. /**
  31779. * Bind the content of a webGL buffer used with instantiation
  31780. * @param instancesBuffer defines the webGL buffer to bind
  31781. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31782. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31783. */
  31784. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31785. /**
  31786. * Disable the instance attribute corresponding to the name in parameter
  31787. * @param name defines the name of the attribute to disable
  31788. */
  31789. disableInstanceAttributeByName(name: string): void;
  31790. /**
  31791. * Disable the instance attribute corresponding to the location in parameter
  31792. * @param attributeLocation defines the attribute location of the attribute to disable
  31793. */
  31794. disableInstanceAttribute(attributeLocation: number): void;
  31795. /**
  31796. * Disable the attribute corresponding to the location in parameter
  31797. * @param attributeLocation defines the attribute location of the attribute to disable
  31798. */
  31799. disableAttributeByIndex(attributeLocation: number): void;
  31800. /**
  31801. * Send a draw order
  31802. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31803. * @param indexStart defines the starting index
  31804. * @param indexCount defines the number of index to draw
  31805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31806. */
  31807. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31808. /**
  31809. * Draw a list of points
  31810. * @param verticesStart defines the index of first vertex to draw
  31811. * @param verticesCount defines the count of vertices to draw
  31812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31813. */
  31814. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31815. /**
  31816. * Draw a list of unindexed primitives
  31817. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31818. * @param verticesStart defines the index of first vertex to draw
  31819. * @param verticesCount defines the count of vertices to draw
  31820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31821. */
  31822. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31823. /**
  31824. * Draw a list of indexed primitives
  31825. * @param fillMode defines the primitive to use
  31826. * @param indexStart defines the starting index
  31827. * @param indexCount defines the number of index to draw
  31828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31829. */
  31830. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31831. /**
  31832. * Draw a list of unindexed primitives
  31833. * @param fillMode defines the primitive to use
  31834. * @param verticesStart defines the index of first vertex to draw
  31835. * @param verticesCount defines the count of vertices to draw
  31836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31837. */
  31838. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31839. private _drawMode;
  31840. /** @hidden */
  31841. protected _reportDrawCall(): void;
  31842. /** @hidden */
  31843. _releaseEffect(effect: Effect): void;
  31844. /** @hidden */
  31845. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31846. /**
  31847. * Create a new effect (used to store vertex/fragment shaders)
  31848. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31849. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31850. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31851. * @param samplers defines an array of string used to represent textures
  31852. * @param defines defines the string containing the defines to use to compile the shaders
  31853. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31854. * @param onCompiled defines a function to call when the effect creation is successful
  31855. * @param onError defines a function to call when the effect creation has failed
  31856. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31857. * @returns the new Effect
  31858. */
  31859. 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;
  31860. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31861. private _compileShader;
  31862. private _compileRawShader;
  31863. /** @hidden */
  31864. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31865. /**
  31866. * Directly creates a webGL program
  31867. * @param pipelineContext defines the pipeline context to attach to
  31868. * @param vertexCode defines the vertex shader code to use
  31869. * @param fragmentCode defines the fragment shader code to use
  31870. * @param context defines the webGL context to use (if not set, the current one will be used)
  31871. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31872. * @returns the new webGL program
  31873. */
  31874. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31875. /**
  31876. * Creates a webGL program
  31877. * @param pipelineContext defines the pipeline context to attach to
  31878. * @param vertexCode defines the vertex shader code to use
  31879. * @param fragmentCode defines the fragment shader code to use
  31880. * @param defines defines the string containing the defines to use to compile the shaders
  31881. * @param context defines the webGL context to use (if not set, the current one will be used)
  31882. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31883. * @returns the new webGL program
  31884. */
  31885. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31886. /**
  31887. * Creates a new pipeline context
  31888. * @returns the new pipeline
  31889. */
  31890. createPipelineContext(): IPipelineContext;
  31891. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31892. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31893. /** @hidden */
  31894. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31895. /** @hidden */
  31896. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31897. /** @hidden */
  31898. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31899. /**
  31900. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31901. * @param pipelineContext defines the pipeline context to use
  31902. * @param uniformsNames defines the list of uniform names
  31903. * @returns an array of webGL uniform locations
  31904. */
  31905. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31906. /**
  31907. * Gets the lsit of active attributes for a given webGL program
  31908. * @param pipelineContext defines the pipeline context to use
  31909. * @param attributesNames defines the list of attribute names to get
  31910. * @returns an array of indices indicating the offset of each attribute
  31911. */
  31912. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31913. /**
  31914. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31915. * @param effect defines the effect to activate
  31916. */
  31917. enableEffect(effect: Nullable<Effect>): void;
  31918. /**
  31919. * Set the value of an uniform to a number (int)
  31920. * @param uniform defines the webGL uniform location where to store the value
  31921. * @param value defines the int number to store
  31922. */
  31923. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31924. /**
  31925. * Set the value of an uniform to an array of int32
  31926. * @param uniform defines the webGL uniform location where to store the value
  31927. * @param array defines the array of int32 to store
  31928. */
  31929. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31930. /**
  31931. * Set the value of an uniform to an array of int32 (stored as vec2)
  31932. * @param uniform defines the webGL uniform location where to store the value
  31933. * @param array defines the array of int32 to store
  31934. */
  31935. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31936. /**
  31937. * Set the value of an uniform to an array of int32 (stored as vec3)
  31938. * @param uniform defines the webGL uniform location where to store the value
  31939. * @param array defines the array of int32 to store
  31940. */
  31941. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31942. /**
  31943. * Set the value of an uniform to an array of int32 (stored as vec4)
  31944. * @param uniform defines the webGL uniform location where to store the value
  31945. * @param array defines the array of int32 to store
  31946. */
  31947. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31948. /**
  31949. * Set the value of an uniform to an array of number
  31950. * @param uniform defines the webGL uniform location where to store the value
  31951. * @param array defines the array of number to store
  31952. */
  31953. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31954. /**
  31955. * Set the value of an uniform to an array of number (stored as vec2)
  31956. * @param uniform defines the webGL uniform location where to store the value
  31957. * @param array defines the array of number to store
  31958. */
  31959. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31960. /**
  31961. * Set the value of an uniform to an array of number (stored as vec3)
  31962. * @param uniform defines the webGL uniform location where to store the value
  31963. * @param array defines the array of number to store
  31964. */
  31965. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31966. /**
  31967. * Set the value of an uniform to an array of number (stored as vec4)
  31968. * @param uniform defines the webGL uniform location where to store the value
  31969. * @param array defines the array of number to store
  31970. */
  31971. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31972. /**
  31973. * Set the value of an uniform to an array of float32 (stored as matrices)
  31974. * @param uniform defines the webGL uniform location where to store the value
  31975. * @param matrices defines the array of float32 to store
  31976. */
  31977. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31978. /**
  31979. * Set the value of an uniform to a matrix (3x3)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31982. */
  31983. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31984. /**
  31985. * Set the value of an uniform to a matrix (2x2)
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31988. */
  31989. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31990. /**
  31991. * Set the value of an uniform to a number (float)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param value defines the float number to store
  31994. */
  31995. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31996. /**
  31997. * Set the value of an uniform to a vec2
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param x defines the 1st component of the value
  32000. * @param y defines the 2nd component of the value
  32001. */
  32002. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32003. /**
  32004. * Set the value of an uniform to a vec3
  32005. * @param uniform defines the webGL uniform location where to store the value
  32006. * @param x defines the 1st component of the value
  32007. * @param y defines the 2nd component of the value
  32008. * @param z defines the 3rd component of the value
  32009. */
  32010. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32011. /**
  32012. * Set the value of an uniform to a vec4
  32013. * @param uniform defines the webGL uniform location where to store the value
  32014. * @param x defines the 1st component of the value
  32015. * @param y defines the 2nd component of the value
  32016. * @param z defines the 3rd component of the value
  32017. * @param w defines the 4th component of the value
  32018. */
  32019. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32020. /**
  32021. * Apply all cached states (depth, culling, stencil and alpha)
  32022. */
  32023. applyStates(): void;
  32024. /**
  32025. * Enable or disable color writing
  32026. * @param enable defines the state to set
  32027. */
  32028. setColorWrite(enable: boolean): void;
  32029. /**
  32030. * Gets a boolean indicating if color writing is enabled
  32031. * @returns the current color writing state
  32032. */
  32033. getColorWrite(): boolean;
  32034. /**
  32035. * Gets the depth culling state manager
  32036. */
  32037. get depthCullingState(): DepthCullingState;
  32038. /**
  32039. * Gets the alpha state manager
  32040. */
  32041. get alphaState(): AlphaState;
  32042. /**
  32043. * Gets the stencil state manager
  32044. */
  32045. get stencilState(): StencilState;
  32046. /**
  32047. * Clears the list of texture accessible through engine.
  32048. * This can help preventing texture load conflict due to name collision.
  32049. */
  32050. clearInternalTexturesCache(): void;
  32051. /**
  32052. * Force the entire cache to be cleared
  32053. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32054. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32055. */
  32056. wipeCaches(bruteForce?: boolean): void;
  32057. /** @hidden */
  32058. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32059. min: number;
  32060. mag: number;
  32061. };
  32062. /** @hidden */
  32063. _createTexture(): WebGLTexture;
  32064. /**
  32065. * Usually called from Texture.ts.
  32066. * Passed information to create a WebGLTexture
  32067. * @param url defines a value which contains one of the following:
  32068. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32069. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32070. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32071. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32072. * @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)
  32073. * @param scene needed for loading to the correct scene
  32074. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32075. * @param onLoad optional callback to be called upon successful completion
  32076. * @param onError optional callback to be called upon failure
  32077. * @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
  32078. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32079. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32080. * @param forcedExtension defines the extension to use to pick the right loader
  32081. * @param mimeType defines an optional mime type
  32082. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32083. */
  32084. createTexture(url: 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>, mimeType?: string): InternalTexture;
  32085. /**
  32086. * Loads an image as an HTMLImageElement.
  32087. * @param input url string, ArrayBuffer, or Blob to load
  32088. * @param onLoad callback called when the image successfully loads
  32089. * @param onError callback called when the image fails to load
  32090. * @param offlineProvider offline provider for caching
  32091. * @param mimeType optional mime type
  32092. * @returns the HTMLImageElement of the loaded image
  32093. * @hidden
  32094. */
  32095. 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>;
  32096. /**
  32097. * @hidden
  32098. */
  32099. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32100. /**
  32101. * Creates a raw texture
  32102. * @param data defines the data to store in the texture
  32103. * @param width defines the width of the texture
  32104. * @param height defines the height of the texture
  32105. * @param format defines the format of the data
  32106. * @param generateMipMaps defines if the engine should generate the mip levels
  32107. * @param invertY defines if data must be stored with Y axis inverted
  32108. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32109. * @param compression defines the compression used (null by default)
  32110. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32111. * @returns the raw texture inside an InternalTexture
  32112. */
  32113. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32114. /**
  32115. * Creates a new raw cube texture
  32116. * @param data defines the array of data to use to create each face
  32117. * @param size defines the size of the textures
  32118. * @param format defines the format of the data
  32119. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32120. * @param generateMipMaps defines if the engine should generate the mip levels
  32121. * @param invertY defines if data must be stored with Y axis inverted
  32122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32123. * @param compression defines the compression used (null by default)
  32124. * @returns the cube texture as an InternalTexture
  32125. */
  32126. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32127. /**
  32128. * Creates a new raw 3D texture
  32129. * @param data defines the data used to create the texture
  32130. * @param width defines the width of the texture
  32131. * @param height defines the height of the texture
  32132. * @param depth defines the depth of the texture
  32133. * @param format defines the format of the texture
  32134. * @param generateMipMaps defines if the engine must generate mip levels
  32135. * @param invertY defines if data must be stored with Y axis inverted
  32136. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32137. * @param compression defines the compressed used (can be null)
  32138. * @param textureType defines the compressed used (can be null)
  32139. * @returns a new raw 3D texture (stored in an InternalTexture)
  32140. */
  32141. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32142. /**
  32143. * Creates a new raw 2D array texture
  32144. * @param data defines the data used to create the texture
  32145. * @param width defines the width of the texture
  32146. * @param height defines the height of the texture
  32147. * @param depth defines the number of layers of the texture
  32148. * @param format defines the format of the texture
  32149. * @param generateMipMaps defines if the engine must generate mip levels
  32150. * @param invertY defines if data must be stored with Y axis inverted
  32151. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32152. * @param compression defines the compressed used (can be null)
  32153. * @param textureType defines the compressed used (can be null)
  32154. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32155. */
  32156. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32157. private _unpackFlipYCached;
  32158. /**
  32159. * In case you are sharing the context with other applications, it might
  32160. * be interested to not cache the unpack flip y state to ensure a consistent
  32161. * value would be set.
  32162. */
  32163. enableUnpackFlipYCached: boolean;
  32164. /** @hidden */
  32165. _unpackFlipY(value: boolean): void;
  32166. /** @hidden */
  32167. _getUnpackAlignement(): number;
  32168. private _getTextureTarget;
  32169. /**
  32170. * Update the sampling mode of a given texture
  32171. * @param samplingMode defines the required sampling mode
  32172. * @param texture defines the texture to update
  32173. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32174. */
  32175. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32176. /**
  32177. * Update the sampling mode of a given texture
  32178. * @param texture defines the texture to update
  32179. * @param wrapU defines the texture wrap mode of the u coordinates
  32180. * @param wrapV defines the texture wrap mode of the v coordinates
  32181. * @param wrapR defines the texture wrap mode of the r coordinates
  32182. */
  32183. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32184. /** @hidden */
  32185. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32186. width: number;
  32187. height: number;
  32188. layers?: number;
  32189. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32190. /** @hidden */
  32191. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32192. /** @hidden */
  32193. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32194. /**
  32195. * Update a portion of an internal texture
  32196. * @param texture defines the texture to update
  32197. * @param imageData defines the data to store into the texture
  32198. * @param xOffset defines the x coordinates of the update rectangle
  32199. * @param yOffset defines the y coordinates of the update rectangle
  32200. * @param width defines the width of the update rectangle
  32201. * @param height defines the height of the update rectangle
  32202. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32203. * @param lod defines the lod level to update (0 by default)
  32204. */
  32205. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32206. /** @hidden */
  32207. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32208. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32209. private _prepareWebGLTexture;
  32210. /** @hidden */
  32211. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32212. private _getDepthStencilBuffer;
  32213. /** @hidden */
  32214. _releaseFramebufferObjects(texture: InternalTexture): void;
  32215. /** @hidden */
  32216. _releaseTexture(texture: InternalTexture): void;
  32217. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32218. protected _setProgram(program: WebGLProgram): void;
  32219. protected _boundUniforms: {
  32220. [key: number]: WebGLUniformLocation;
  32221. };
  32222. /**
  32223. * Binds an effect to the webGL context
  32224. * @param effect defines the effect to bind
  32225. */
  32226. bindSamplers(effect: Effect): void;
  32227. private _activateCurrentTexture;
  32228. /** @hidden */
  32229. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32230. /** @hidden */
  32231. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32232. /**
  32233. * Unbind all textures from the webGL context
  32234. */
  32235. unbindAllTextures(): void;
  32236. /**
  32237. * Sets a texture to the according uniform.
  32238. * @param channel The texture channel
  32239. * @param uniform The uniform to set
  32240. * @param texture The texture to apply
  32241. */
  32242. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32243. private _bindSamplerUniformToChannel;
  32244. private _getTextureWrapMode;
  32245. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32246. /**
  32247. * Sets an array of texture to the webGL context
  32248. * @param channel defines the channel where the texture array must be set
  32249. * @param uniform defines the associated uniform location
  32250. * @param textures defines the array of textures to bind
  32251. */
  32252. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32253. /** @hidden */
  32254. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32255. private _setTextureParameterFloat;
  32256. private _setTextureParameterInteger;
  32257. /**
  32258. * Unbind all vertex attributes from the webGL context
  32259. */
  32260. unbindAllAttributes(): void;
  32261. /**
  32262. * 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
  32263. */
  32264. releaseEffects(): void;
  32265. /**
  32266. * Dispose and release all associated resources
  32267. */
  32268. dispose(): void;
  32269. /**
  32270. * Attach a new callback raised when context lost event is fired
  32271. * @param callback defines the callback to call
  32272. */
  32273. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32274. /**
  32275. * Attach a new callback raised when context restored event is fired
  32276. * @param callback defines the callback to call
  32277. */
  32278. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32279. /**
  32280. * Get the current error code of the webGL context
  32281. * @returns the error code
  32282. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32283. */
  32284. getError(): number;
  32285. private _canRenderToFloatFramebuffer;
  32286. private _canRenderToHalfFloatFramebuffer;
  32287. private _canRenderToFramebuffer;
  32288. /** @hidden */
  32289. _getWebGLTextureType(type: number): number;
  32290. /** @hidden */
  32291. _getInternalFormat(format: number): number;
  32292. /** @hidden */
  32293. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32294. /** @hidden */
  32295. _getRGBAMultiSampleBufferFormat(type: number): number;
  32296. /** @hidden */
  32297. _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;
  32298. /**
  32299. * Loads a file from a url
  32300. * @param url url to load
  32301. * @param onSuccess callback called when the file successfully loads
  32302. * @param onProgress callback called while file is loading (if the server supports this mode)
  32303. * @param offlineProvider defines the offline provider for caching
  32304. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32305. * @param onError callback called when the file fails to load
  32306. * @returns a file request object
  32307. * @hidden
  32308. */
  32309. 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;
  32310. /**
  32311. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32312. * @param x defines the x coordinate of the rectangle where pixels must be read
  32313. * @param y defines the y coordinate of the rectangle where pixels must be read
  32314. * @param width defines the width of the rectangle where pixels must be read
  32315. * @param height defines the height of the rectangle where pixels must be read
  32316. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32317. * @returns a Uint8Array containing RGBA colors
  32318. */
  32319. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32320. private static _isSupported;
  32321. /**
  32322. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32323. * @returns true if the engine can be created
  32324. * @ignorenaming
  32325. */
  32326. static isSupported(): boolean;
  32327. /**
  32328. * Find the next highest power of two.
  32329. * @param x Number to start search from.
  32330. * @return Next highest power of two.
  32331. */
  32332. static CeilingPOT(x: number): number;
  32333. /**
  32334. * Find the next lowest power of two.
  32335. * @param x Number to start search from.
  32336. * @return Next lowest power of two.
  32337. */
  32338. static FloorPOT(x: number): number;
  32339. /**
  32340. * Find the nearest power of two.
  32341. * @param x Number to start search from.
  32342. * @return Next nearest power of two.
  32343. */
  32344. static NearestPOT(x: number): number;
  32345. /**
  32346. * Get the closest exponent of two
  32347. * @param value defines the value to approximate
  32348. * @param max defines the maximum value to return
  32349. * @param mode defines how to define the closest value
  32350. * @returns closest exponent of two of the given value
  32351. */
  32352. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32353. /**
  32354. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32355. * @param func - the function to be called
  32356. * @param requester - the object that will request the next frame. Falls back to window.
  32357. * @returns frame number
  32358. */
  32359. static QueueNewFrame(func: () => void, requester?: any): number;
  32360. /**
  32361. * Gets host document
  32362. * @returns the host document object
  32363. */
  32364. getHostDocument(): Nullable<Document>;
  32365. }
  32366. }
  32367. declare module BABYLON {
  32368. /**
  32369. * Class representing spherical harmonics coefficients to the 3rd degree
  32370. */
  32371. export class SphericalHarmonics {
  32372. /**
  32373. * Defines whether or not the harmonics have been prescaled for rendering.
  32374. */
  32375. preScaled: boolean;
  32376. /**
  32377. * The l0,0 coefficients of the spherical harmonics
  32378. */
  32379. l00: Vector3;
  32380. /**
  32381. * The l1,-1 coefficients of the spherical harmonics
  32382. */
  32383. l1_1: Vector3;
  32384. /**
  32385. * The l1,0 coefficients of the spherical harmonics
  32386. */
  32387. l10: Vector3;
  32388. /**
  32389. * The l1,1 coefficients of the spherical harmonics
  32390. */
  32391. l11: Vector3;
  32392. /**
  32393. * The l2,-2 coefficients of the spherical harmonics
  32394. */
  32395. l2_2: Vector3;
  32396. /**
  32397. * The l2,-1 coefficients of the spherical harmonics
  32398. */
  32399. l2_1: Vector3;
  32400. /**
  32401. * The l2,0 coefficients of the spherical harmonics
  32402. */
  32403. l20: Vector3;
  32404. /**
  32405. * The l2,1 coefficients of the spherical harmonics
  32406. */
  32407. l21: Vector3;
  32408. /**
  32409. * The l2,2 coefficients of the spherical harmonics
  32410. */
  32411. l22: Vector3;
  32412. /**
  32413. * Adds a light to the spherical harmonics
  32414. * @param direction the direction of the light
  32415. * @param color the color of the light
  32416. * @param deltaSolidAngle the delta solid angle of the light
  32417. */
  32418. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32419. /**
  32420. * Scales the spherical harmonics by the given amount
  32421. * @param scale the amount to scale
  32422. */
  32423. scaleInPlace(scale: number): void;
  32424. /**
  32425. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32426. *
  32427. * ```
  32428. * E_lm = A_l * L_lm
  32429. * ```
  32430. *
  32431. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32432. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32433. * the scaling factors are given in equation 9.
  32434. */
  32435. convertIncidentRadianceToIrradiance(): void;
  32436. /**
  32437. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32438. *
  32439. * ```
  32440. * L = (1/pi) * E * rho
  32441. * ```
  32442. *
  32443. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32444. */
  32445. convertIrradianceToLambertianRadiance(): void;
  32446. /**
  32447. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32448. * required operations at run time.
  32449. *
  32450. * This is simply done by scaling back the SH with Ylm constants parameter.
  32451. * The trigonometric part being applied by the shader at run time.
  32452. */
  32453. preScaleForRendering(): void;
  32454. /**
  32455. * Constructs a spherical harmonics from an array.
  32456. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32457. * @returns the spherical harmonics
  32458. */
  32459. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32460. /**
  32461. * Gets the spherical harmonics from polynomial
  32462. * @param polynomial the spherical polynomial
  32463. * @returns the spherical harmonics
  32464. */
  32465. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32466. }
  32467. /**
  32468. * Class representing spherical polynomial coefficients to the 3rd degree
  32469. */
  32470. export class SphericalPolynomial {
  32471. private _harmonics;
  32472. /**
  32473. * The spherical harmonics used to create the polynomials.
  32474. */
  32475. get preScaledHarmonics(): SphericalHarmonics;
  32476. /**
  32477. * The x coefficients of the spherical polynomial
  32478. */
  32479. x: Vector3;
  32480. /**
  32481. * The y coefficients of the spherical polynomial
  32482. */
  32483. y: Vector3;
  32484. /**
  32485. * The z coefficients of the spherical polynomial
  32486. */
  32487. z: Vector3;
  32488. /**
  32489. * The xx coefficients of the spherical polynomial
  32490. */
  32491. xx: Vector3;
  32492. /**
  32493. * The yy coefficients of the spherical polynomial
  32494. */
  32495. yy: Vector3;
  32496. /**
  32497. * The zz coefficients of the spherical polynomial
  32498. */
  32499. zz: Vector3;
  32500. /**
  32501. * The xy coefficients of the spherical polynomial
  32502. */
  32503. xy: Vector3;
  32504. /**
  32505. * The yz coefficients of the spherical polynomial
  32506. */
  32507. yz: Vector3;
  32508. /**
  32509. * The zx coefficients of the spherical polynomial
  32510. */
  32511. zx: Vector3;
  32512. /**
  32513. * Adds an ambient color to the spherical polynomial
  32514. * @param color the color to add
  32515. */
  32516. addAmbient(color: Color3): void;
  32517. /**
  32518. * Scales the spherical polynomial by the given amount
  32519. * @param scale the amount to scale
  32520. */
  32521. scaleInPlace(scale: number): void;
  32522. /**
  32523. * Gets the spherical polynomial from harmonics
  32524. * @param harmonics the spherical harmonics
  32525. * @returns the spherical polynomial
  32526. */
  32527. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32528. /**
  32529. * Constructs a spherical polynomial from an array.
  32530. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32531. * @returns the spherical polynomial
  32532. */
  32533. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32534. }
  32535. }
  32536. declare module BABYLON {
  32537. /**
  32538. * Defines the source of the internal texture
  32539. */
  32540. export enum InternalTextureSource {
  32541. /**
  32542. * The source of the texture data is unknown
  32543. */
  32544. Unknown = 0,
  32545. /**
  32546. * Texture data comes from an URL
  32547. */
  32548. Url = 1,
  32549. /**
  32550. * Texture data is only used for temporary storage
  32551. */
  32552. Temp = 2,
  32553. /**
  32554. * Texture data comes from raw data (ArrayBuffer)
  32555. */
  32556. Raw = 3,
  32557. /**
  32558. * Texture content is dynamic (video or dynamic texture)
  32559. */
  32560. Dynamic = 4,
  32561. /**
  32562. * Texture content is generated by rendering to it
  32563. */
  32564. RenderTarget = 5,
  32565. /**
  32566. * Texture content is part of a multi render target process
  32567. */
  32568. MultiRenderTarget = 6,
  32569. /**
  32570. * Texture data comes from a cube data file
  32571. */
  32572. Cube = 7,
  32573. /**
  32574. * Texture data comes from a raw cube data
  32575. */
  32576. CubeRaw = 8,
  32577. /**
  32578. * Texture data come from a prefiltered cube data file
  32579. */
  32580. CubePrefiltered = 9,
  32581. /**
  32582. * Texture content is raw 3D data
  32583. */
  32584. Raw3D = 10,
  32585. /**
  32586. * Texture content is raw 2D array data
  32587. */
  32588. Raw2DArray = 11,
  32589. /**
  32590. * Texture content is a depth texture
  32591. */
  32592. Depth = 12,
  32593. /**
  32594. * Texture data comes from a raw cube data encoded with RGBD
  32595. */
  32596. CubeRawRGBD = 13
  32597. }
  32598. /**
  32599. * Class used to store data associated with WebGL texture data for the engine
  32600. * This class should not be used directly
  32601. */
  32602. export class InternalTexture {
  32603. /** @hidden */
  32604. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32605. /**
  32606. * Defines if the texture is ready
  32607. */
  32608. isReady: boolean;
  32609. /**
  32610. * Defines if the texture is a cube texture
  32611. */
  32612. isCube: boolean;
  32613. /**
  32614. * Defines if the texture contains 3D data
  32615. */
  32616. is3D: boolean;
  32617. /**
  32618. * Defines if the texture contains 2D array data
  32619. */
  32620. is2DArray: boolean;
  32621. /**
  32622. * Defines if the texture contains multiview data
  32623. */
  32624. isMultiview: boolean;
  32625. /**
  32626. * Gets the URL used to load this texture
  32627. */
  32628. url: string;
  32629. /**
  32630. * Gets the sampling mode of the texture
  32631. */
  32632. samplingMode: number;
  32633. /**
  32634. * Gets a boolean indicating if the texture needs mipmaps generation
  32635. */
  32636. generateMipMaps: boolean;
  32637. /**
  32638. * Gets the number of samples used by the texture (WebGL2+ only)
  32639. */
  32640. samples: number;
  32641. /**
  32642. * Gets the type of the texture (int, float...)
  32643. */
  32644. type: number;
  32645. /**
  32646. * Gets the format of the texture (RGB, RGBA...)
  32647. */
  32648. format: number;
  32649. /**
  32650. * Observable called when the texture is loaded
  32651. */
  32652. onLoadedObservable: Observable<InternalTexture>;
  32653. /**
  32654. * Gets the width of the texture
  32655. */
  32656. width: number;
  32657. /**
  32658. * Gets the height of the texture
  32659. */
  32660. height: number;
  32661. /**
  32662. * Gets the depth of the texture
  32663. */
  32664. depth: number;
  32665. /**
  32666. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32667. */
  32668. baseWidth: number;
  32669. /**
  32670. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32671. */
  32672. baseHeight: number;
  32673. /**
  32674. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32675. */
  32676. baseDepth: number;
  32677. /**
  32678. * Gets a boolean indicating if the texture is inverted on Y axis
  32679. */
  32680. invertY: boolean;
  32681. /** @hidden */
  32682. _invertVScale: boolean;
  32683. /** @hidden */
  32684. _associatedChannel: number;
  32685. /** @hidden */
  32686. _source: InternalTextureSource;
  32687. /** @hidden */
  32688. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32689. /** @hidden */
  32690. _bufferView: Nullable<ArrayBufferView>;
  32691. /** @hidden */
  32692. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32693. /** @hidden */
  32694. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32695. /** @hidden */
  32696. _size: number;
  32697. /** @hidden */
  32698. _extension: string;
  32699. /** @hidden */
  32700. _files: Nullable<string[]>;
  32701. /** @hidden */
  32702. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32703. /** @hidden */
  32704. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32705. /** @hidden */
  32706. _framebuffer: Nullable<WebGLFramebuffer>;
  32707. /** @hidden */
  32708. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32709. /** @hidden */
  32710. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32711. /** @hidden */
  32712. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32713. /** @hidden */
  32714. _attachments: Nullable<number[]>;
  32715. /** @hidden */
  32716. _cachedCoordinatesMode: Nullable<number>;
  32717. /** @hidden */
  32718. _cachedWrapU: Nullable<number>;
  32719. /** @hidden */
  32720. _cachedWrapV: Nullable<number>;
  32721. /** @hidden */
  32722. _cachedWrapR: Nullable<number>;
  32723. /** @hidden */
  32724. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32725. /** @hidden */
  32726. _isDisabled: boolean;
  32727. /** @hidden */
  32728. _compression: Nullable<string>;
  32729. /** @hidden */
  32730. _generateStencilBuffer: boolean;
  32731. /** @hidden */
  32732. _generateDepthBuffer: boolean;
  32733. /** @hidden */
  32734. _comparisonFunction: number;
  32735. /** @hidden */
  32736. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32737. /** @hidden */
  32738. _lodGenerationScale: number;
  32739. /** @hidden */
  32740. _lodGenerationOffset: number;
  32741. /** @hidden */
  32742. _depthStencilTexture: Nullable<InternalTexture>;
  32743. /** @hidden */
  32744. _colorTextureArray: Nullable<WebGLTexture>;
  32745. /** @hidden */
  32746. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32747. /** @hidden */
  32748. _lodTextureHigh: Nullable<BaseTexture>;
  32749. /** @hidden */
  32750. _lodTextureMid: Nullable<BaseTexture>;
  32751. /** @hidden */
  32752. _lodTextureLow: Nullable<BaseTexture>;
  32753. /** @hidden */
  32754. _isRGBD: boolean;
  32755. /** @hidden */
  32756. _linearSpecularLOD: boolean;
  32757. /** @hidden */
  32758. _irradianceTexture: Nullable<BaseTexture>;
  32759. /** @hidden */
  32760. _webGLTexture: Nullable<WebGLTexture>;
  32761. /** @hidden */
  32762. _references: number;
  32763. private _engine;
  32764. /**
  32765. * Gets the Engine the texture belongs to.
  32766. * @returns The babylon engine
  32767. */
  32768. getEngine(): ThinEngine;
  32769. /**
  32770. * Gets the data source type of the texture
  32771. */
  32772. get source(): InternalTextureSource;
  32773. /**
  32774. * Creates a new InternalTexture
  32775. * @param engine defines the engine to use
  32776. * @param source defines the type of data that will be used
  32777. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32778. */
  32779. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32780. /**
  32781. * Increments the number of references (ie. the number of Texture that point to it)
  32782. */
  32783. incrementReferences(): void;
  32784. /**
  32785. * Change the size of the texture (not the size of the content)
  32786. * @param width defines the new width
  32787. * @param height defines the new height
  32788. * @param depth defines the new depth (1 by default)
  32789. */
  32790. updateSize(width: int, height: int, depth?: int): void;
  32791. /** @hidden */
  32792. _rebuild(): void;
  32793. /** @hidden */
  32794. _swapAndDie(target: InternalTexture): void;
  32795. /**
  32796. * Dispose the current allocated resources
  32797. */
  32798. dispose(): void;
  32799. }
  32800. }
  32801. declare module BABYLON {
  32802. /**
  32803. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32805. */
  32806. export class Analyser {
  32807. /**
  32808. * Gets or sets the smoothing
  32809. * @ignorenaming
  32810. */
  32811. SMOOTHING: number;
  32812. /**
  32813. * Gets or sets the FFT table size
  32814. * @ignorenaming
  32815. */
  32816. FFT_SIZE: number;
  32817. /**
  32818. * Gets or sets the bar graph amplitude
  32819. * @ignorenaming
  32820. */
  32821. BARGRAPHAMPLITUDE: number;
  32822. /**
  32823. * Gets or sets the position of the debug canvas
  32824. * @ignorenaming
  32825. */
  32826. DEBUGCANVASPOS: {
  32827. x: number;
  32828. y: number;
  32829. };
  32830. /**
  32831. * Gets or sets the debug canvas size
  32832. * @ignorenaming
  32833. */
  32834. DEBUGCANVASSIZE: {
  32835. width: number;
  32836. height: number;
  32837. };
  32838. private _byteFreqs;
  32839. private _byteTime;
  32840. private _floatFreqs;
  32841. private _webAudioAnalyser;
  32842. private _debugCanvas;
  32843. private _debugCanvasContext;
  32844. private _scene;
  32845. private _registerFunc;
  32846. private _audioEngine;
  32847. /**
  32848. * Creates a new analyser
  32849. * @param scene defines hosting scene
  32850. */
  32851. constructor(scene: Scene);
  32852. /**
  32853. * Get the number of data values you will have to play with for the visualization
  32854. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32855. * @returns a number
  32856. */
  32857. getFrequencyBinCount(): number;
  32858. /**
  32859. * Gets the current frequency data as a byte array
  32860. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32861. * @returns a Uint8Array
  32862. */
  32863. getByteFrequencyData(): Uint8Array;
  32864. /**
  32865. * Gets the current waveform as a byte array
  32866. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32867. * @returns a Uint8Array
  32868. */
  32869. getByteTimeDomainData(): Uint8Array;
  32870. /**
  32871. * Gets the current frequency data as a float array
  32872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32873. * @returns a Float32Array
  32874. */
  32875. getFloatFrequencyData(): Float32Array;
  32876. /**
  32877. * Renders the debug canvas
  32878. */
  32879. drawDebugCanvas(): void;
  32880. /**
  32881. * Stops rendering the debug canvas and removes it
  32882. */
  32883. stopDebugCanvas(): void;
  32884. /**
  32885. * Connects two audio nodes
  32886. * @param inputAudioNode defines first node to connect
  32887. * @param outputAudioNode defines second node to connect
  32888. */
  32889. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32890. /**
  32891. * Releases all associated resources
  32892. */
  32893. dispose(): void;
  32894. }
  32895. }
  32896. declare module BABYLON {
  32897. /**
  32898. * This represents an audio engine and it is responsible
  32899. * to play, synchronize and analyse sounds throughout the application.
  32900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32901. */
  32902. export interface IAudioEngine extends IDisposable {
  32903. /**
  32904. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32905. */
  32906. readonly canUseWebAudio: boolean;
  32907. /**
  32908. * Gets the current AudioContext if available.
  32909. */
  32910. readonly audioContext: Nullable<AudioContext>;
  32911. /**
  32912. * The master gain node defines the global audio volume of your audio engine.
  32913. */
  32914. readonly masterGain: GainNode;
  32915. /**
  32916. * Gets whether or not mp3 are supported by your browser.
  32917. */
  32918. readonly isMP3supported: boolean;
  32919. /**
  32920. * Gets whether or not ogg are supported by your browser.
  32921. */
  32922. readonly isOGGsupported: boolean;
  32923. /**
  32924. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32925. * @ignoreNaming
  32926. */
  32927. WarnedWebAudioUnsupported: boolean;
  32928. /**
  32929. * Defines if the audio engine relies on a custom unlocked button.
  32930. * In this case, the embedded button will not be displayed.
  32931. */
  32932. useCustomUnlockedButton: boolean;
  32933. /**
  32934. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32935. */
  32936. readonly unlocked: boolean;
  32937. /**
  32938. * Event raised when audio has been unlocked on the browser.
  32939. */
  32940. onAudioUnlockedObservable: Observable<AudioEngine>;
  32941. /**
  32942. * Event raised when audio has been locked on the browser.
  32943. */
  32944. onAudioLockedObservable: Observable<AudioEngine>;
  32945. /**
  32946. * Flags the audio engine in Locked state.
  32947. * This happens due to new browser policies preventing audio to autoplay.
  32948. */
  32949. lock(): void;
  32950. /**
  32951. * Unlocks the audio engine once a user action has been done on the dom.
  32952. * This is helpful to resume play once browser policies have been satisfied.
  32953. */
  32954. unlock(): void;
  32955. /**
  32956. * Gets the global volume sets on the master gain.
  32957. * @returns the global volume if set or -1 otherwise
  32958. */
  32959. getGlobalVolume(): number;
  32960. /**
  32961. * Sets the global volume of your experience (sets on the master gain).
  32962. * @param newVolume Defines the new global volume of the application
  32963. */
  32964. setGlobalVolume(newVolume: number): void;
  32965. /**
  32966. * Connect the audio engine to an audio analyser allowing some amazing
  32967. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32969. * @param analyser The analyser to connect to the engine
  32970. */
  32971. connectToAnalyser(analyser: Analyser): void;
  32972. }
  32973. /**
  32974. * This represents the default audio engine used in babylon.
  32975. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32977. */
  32978. export class AudioEngine implements IAudioEngine {
  32979. private _audioContext;
  32980. private _audioContextInitialized;
  32981. private _muteButton;
  32982. private _hostElement;
  32983. /**
  32984. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32985. */
  32986. canUseWebAudio: boolean;
  32987. /**
  32988. * The master gain node defines the global audio volume of your audio engine.
  32989. */
  32990. masterGain: GainNode;
  32991. /**
  32992. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32993. * @ignoreNaming
  32994. */
  32995. WarnedWebAudioUnsupported: boolean;
  32996. /**
  32997. * Gets whether or not mp3 are supported by your browser.
  32998. */
  32999. isMP3supported: boolean;
  33000. /**
  33001. * Gets whether or not ogg are supported by your browser.
  33002. */
  33003. isOGGsupported: boolean;
  33004. /**
  33005. * Gets whether audio has been unlocked on the device.
  33006. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33007. * a user interaction has happened.
  33008. */
  33009. unlocked: boolean;
  33010. /**
  33011. * Defines if the audio engine relies on a custom unlocked button.
  33012. * In this case, the embedded button will not be displayed.
  33013. */
  33014. useCustomUnlockedButton: boolean;
  33015. /**
  33016. * Event raised when audio has been unlocked on the browser.
  33017. */
  33018. onAudioUnlockedObservable: Observable<AudioEngine>;
  33019. /**
  33020. * Event raised when audio has been locked on the browser.
  33021. */
  33022. onAudioLockedObservable: Observable<AudioEngine>;
  33023. /**
  33024. * Gets the current AudioContext if available.
  33025. */
  33026. get audioContext(): Nullable<AudioContext>;
  33027. private _connectedAnalyser;
  33028. /**
  33029. * Instantiates a new audio engine.
  33030. *
  33031. * There should be only one per page as some browsers restrict the number
  33032. * of audio contexts you can create.
  33033. * @param hostElement defines the host element where to display the mute icon if necessary
  33034. */
  33035. constructor(hostElement?: Nullable<HTMLElement>);
  33036. /**
  33037. * Flags the audio engine in Locked state.
  33038. * This happens due to new browser policies preventing audio to autoplay.
  33039. */
  33040. lock(): void;
  33041. /**
  33042. * Unlocks the audio engine once a user action has been done on the dom.
  33043. * This is helpful to resume play once browser policies have been satisfied.
  33044. */
  33045. unlock(): void;
  33046. private _resumeAudioContext;
  33047. private _initializeAudioContext;
  33048. private _tryToRun;
  33049. private _triggerRunningState;
  33050. private _triggerSuspendedState;
  33051. private _displayMuteButton;
  33052. private _moveButtonToTopLeft;
  33053. private _onResize;
  33054. private _hideMuteButton;
  33055. /**
  33056. * Destroy and release the resources associated with the audio ccontext.
  33057. */
  33058. dispose(): void;
  33059. /**
  33060. * Gets the global volume sets on the master gain.
  33061. * @returns the global volume if set or -1 otherwise
  33062. */
  33063. getGlobalVolume(): number;
  33064. /**
  33065. * Sets the global volume of your experience (sets on the master gain).
  33066. * @param newVolume Defines the new global volume of the application
  33067. */
  33068. setGlobalVolume(newVolume: number): void;
  33069. /**
  33070. * Connect the audio engine to an audio analyser allowing some amazing
  33071. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33073. * @param analyser The analyser to connect to the engine
  33074. */
  33075. connectToAnalyser(analyser: Analyser): void;
  33076. }
  33077. }
  33078. declare module BABYLON {
  33079. /**
  33080. * Interface used to present a loading screen while loading a scene
  33081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33082. */
  33083. export interface ILoadingScreen {
  33084. /**
  33085. * Function called to display the loading screen
  33086. */
  33087. displayLoadingUI: () => void;
  33088. /**
  33089. * Function called to hide the loading screen
  33090. */
  33091. hideLoadingUI: () => void;
  33092. /**
  33093. * Gets or sets the color to use for the background
  33094. */
  33095. loadingUIBackgroundColor: string;
  33096. /**
  33097. * Gets or sets the text to display while loading
  33098. */
  33099. loadingUIText: string;
  33100. }
  33101. /**
  33102. * Class used for the default loading screen
  33103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33104. */
  33105. export class DefaultLoadingScreen implements ILoadingScreen {
  33106. private _renderingCanvas;
  33107. private _loadingText;
  33108. private _loadingDivBackgroundColor;
  33109. private _loadingDiv;
  33110. private _loadingTextDiv;
  33111. /** Gets or sets the logo url to use for the default loading screen */
  33112. static DefaultLogoUrl: string;
  33113. /** Gets or sets the spinner url to use for the default loading screen */
  33114. static DefaultSpinnerUrl: string;
  33115. /**
  33116. * Creates a new default loading screen
  33117. * @param _renderingCanvas defines the canvas used to render the scene
  33118. * @param _loadingText defines the default text to display
  33119. * @param _loadingDivBackgroundColor defines the default background color
  33120. */
  33121. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33122. /**
  33123. * Function called to display the loading screen
  33124. */
  33125. displayLoadingUI(): void;
  33126. /**
  33127. * Function called to hide the loading screen
  33128. */
  33129. hideLoadingUI(): void;
  33130. /**
  33131. * Gets or sets the text to display while loading
  33132. */
  33133. set loadingUIText(text: string);
  33134. get loadingUIText(): string;
  33135. /**
  33136. * Gets or sets the color to use for the background
  33137. */
  33138. get loadingUIBackgroundColor(): string;
  33139. set loadingUIBackgroundColor(color: string);
  33140. private _resizeLoadingUI;
  33141. }
  33142. }
  33143. declare module BABYLON {
  33144. /**
  33145. * Interface for any object that can request an animation frame
  33146. */
  33147. export interface ICustomAnimationFrameRequester {
  33148. /**
  33149. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33150. */
  33151. renderFunction?: Function;
  33152. /**
  33153. * Called to request the next frame to render to
  33154. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33155. */
  33156. requestAnimationFrame: Function;
  33157. /**
  33158. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33159. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33160. */
  33161. requestID?: number;
  33162. }
  33163. }
  33164. declare module BABYLON {
  33165. /**
  33166. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33167. */
  33168. export class PerformanceMonitor {
  33169. private _enabled;
  33170. private _rollingFrameTime;
  33171. private _lastFrameTimeMs;
  33172. /**
  33173. * constructor
  33174. * @param frameSampleSize The number of samples required to saturate the sliding window
  33175. */
  33176. constructor(frameSampleSize?: number);
  33177. /**
  33178. * Samples current frame
  33179. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33180. */
  33181. sampleFrame(timeMs?: number): void;
  33182. /**
  33183. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33184. */
  33185. get averageFrameTime(): number;
  33186. /**
  33187. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33188. */
  33189. get averageFrameTimeVariance(): number;
  33190. /**
  33191. * Returns the frame time of the most recent frame
  33192. */
  33193. get instantaneousFrameTime(): number;
  33194. /**
  33195. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33196. */
  33197. get averageFPS(): number;
  33198. /**
  33199. * Returns the average framerate in frames per second using the most recent frame time
  33200. */
  33201. get instantaneousFPS(): number;
  33202. /**
  33203. * Returns true if enough samples have been taken to completely fill the sliding window
  33204. */
  33205. get isSaturated(): boolean;
  33206. /**
  33207. * Enables contributions to the sliding window sample set
  33208. */
  33209. enable(): void;
  33210. /**
  33211. * Disables contributions to the sliding window sample set
  33212. * Samples will not be interpolated over the disabled period
  33213. */
  33214. disable(): void;
  33215. /**
  33216. * Returns true if sampling is enabled
  33217. */
  33218. get isEnabled(): boolean;
  33219. /**
  33220. * Resets performance monitor
  33221. */
  33222. reset(): void;
  33223. }
  33224. /**
  33225. * RollingAverage
  33226. *
  33227. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33228. */
  33229. export class RollingAverage {
  33230. /**
  33231. * Current average
  33232. */
  33233. average: number;
  33234. /**
  33235. * Current variance
  33236. */
  33237. variance: number;
  33238. protected _samples: Array<number>;
  33239. protected _sampleCount: number;
  33240. protected _pos: number;
  33241. protected _m2: number;
  33242. /**
  33243. * constructor
  33244. * @param length The number of samples required to saturate the sliding window
  33245. */
  33246. constructor(length: number);
  33247. /**
  33248. * Adds a sample to the sample set
  33249. * @param v The sample value
  33250. */
  33251. add(v: number): void;
  33252. /**
  33253. * Returns previously added values or null if outside of history or outside the sliding window domain
  33254. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33255. * @return Value previously recorded with add() or null if outside of range
  33256. */
  33257. history(i: number): number;
  33258. /**
  33259. * Returns true if enough samples have been taken to completely fill the sliding window
  33260. * @return true if sample-set saturated
  33261. */
  33262. isSaturated(): boolean;
  33263. /**
  33264. * Resets the rolling average (equivalent to 0 samples taken so far)
  33265. */
  33266. reset(): void;
  33267. /**
  33268. * Wraps a value around the sample range boundaries
  33269. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33270. * @return Wrapped position in sample range
  33271. */
  33272. protected _wrapPosition(i: number): number;
  33273. }
  33274. }
  33275. declare module BABYLON {
  33276. /**
  33277. * This class is used to track a performance counter which is number based.
  33278. * The user has access to many properties which give statistics of different nature.
  33279. *
  33280. * The implementer can track two kinds of Performance Counter: time and count.
  33281. * 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.
  33282. * 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.
  33283. */
  33284. export class PerfCounter {
  33285. /**
  33286. * Gets or sets a global boolean to turn on and off all the counters
  33287. */
  33288. static Enabled: boolean;
  33289. /**
  33290. * Returns the smallest value ever
  33291. */
  33292. get min(): number;
  33293. /**
  33294. * Returns the biggest value ever
  33295. */
  33296. get max(): number;
  33297. /**
  33298. * Returns the average value since the performance counter is running
  33299. */
  33300. get average(): number;
  33301. /**
  33302. * Returns the average value of the last second the counter was monitored
  33303. */
  33304. get lastSecAverage(): number;
  33305. /**
  33306. * Returns the current value
  33307. */
  33308. get current(): number;
  33309. /**
  33310. * Gets the accumulated total
  33311. */
  33312. get total(): number;
  33313. /**
  33314. * Gets the total value count
  33315. */
  33316. get count(): number;
  33317. /**
  33318. * Creates a new counter
  33319. */
  33320. constructor();
  33321. /**
  33322. * Call this method to start monitoring a new frame.
  33323. * 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.
  33324. */
  33325. fetchNewFrame(): void;
  33326. /**
  33327. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33328. * @param newCount the count value to add to the monitored count
  33329. * @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.
  33330. */
  33331. addCount(newCount: number, fetchResult: boolean): void;
  33332. /**
  33333. * Start monitoring this performance counter
  33334. */
  33335. beginMonitoring(): void;
  33336. /**
  33337. * Compute the time lapsed since the previous beginMonitoring() call.
  33338. * @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
  33339. */
  33340. endMonitoring(newFrame?: boolean): void;
  33341. private _fetchResult;
  33342. private _startMonitoringTime;
  33343. private _min;
  33344. private _max;
  33345. private _average;
  33346. private _current;
  33347. private _totalValueCount;
  33348. private _totalAccumulated;
  33349. private _lastSecAverage;
  33350. private _lastSecAccumulated;
  33351. private _lastSecTime;
  33352. private _lastSecValueCount;
  33353. }
  33354. }
  33355. declare module BABYLON {
  33356. interface ThinEngine {
  33357. /**
  33358. * Sets alpha constants used by some alpha blending modes
  33359. * @param r defines the red component
  33360. * @param g defines the green component
  33361. * @param b defines the blue component
  33362. * @param a defines the alpha component
  33363. */
  33364. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33365. /**
  33366. * Sets the current alpha mode
  33367. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33368. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33369. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33370. */
  33371. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33372. /**
  33373. * Gets the current alpha mode
  33374. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33375. * @returns the current alpha mode
  33376. */
  33377. getAlphaMode(): number;
  33378. /**
  33379. * Sets the current alpha equation
  33380. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33381. */
  33382. setAlphaEquation(equation: number): void;
  33383. /**
  33384. * Gets the current alpha equation.
  33385. * @returns the current alpha equation
  33386. */
  33387. getAlphaEquation(): number;
  33388. }
  33389. }
  33390. declare module BABYLON {
  33391. /**
  33392. * Defines the interface used by display changed events
  33393. */
  33394. export interface IDisplayChangedEventArgs {
  33395. /** Gets the vrDisplay object (if any) */
  33396. vrDisplay: Nullable<any>;
  33397. /** Gets a boolean indicating if webVR is supported */
  33398. vrSupported: boolean;
  33399. }
  33400. /**
  33401. * Defines the interface used by objects containing a viewport (like a camera)
  33402. */
  33403. interface IViewportOwnerLike {
  33404. /**
  33405. * Gets or sets the viewport
  33406. */
  33407. viewport: IViewportLike;
  33408. }
  33409. /**
  33410. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33411. */
  33412. export class Engine extends ThinEngine {
  33413. /** Defines that alpha blending is disabled */
  33414. static readonly ALPHA_DISABLE: number;
  33415. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33416. static readonly ALPHA_ADD: number;
  33417. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33418. static readonly ALPHA_COMBINE: number;
  33419. /** Defines that alpha blending to DEST - SRC * DEST */
  33420. static readonly ALPHA_SUBTRACT: number;
  33421. /** Defines that alpha blending to SRC * DEST */
  33422. static readonly ALPHA_MULTIPLY: number;
  33423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33424. static readonly ALPHA_MAXIMIZED: number;
  33425. /** Defines that alpha blending to SRC + DEST */
  33426. static readonly ALPHA_ONEONE: number;
  33427. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33428. static readonly ALPHA_PREMULTIPLIED: number;
  33429. /**
  33430. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33431. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33432. */
  33433. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33434. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33435. static readonly ALPHA_INTERPOLATE: number;
  33436. /**
  33437. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33438. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33439. */
  33440. static readonly ALPHA_SCREENMODE: number;
  33441. /** Defines that the ressource is not delayed*/
  33442. static readonly DELAYLOADSTATE_NONE: number;
  33443. /** Defines that the ressource was successfully delay loaded */
  33444. static readonly DELAYLOADSTATE_LOADED: number;
  33445. /** Defines that the ressource is currently delay loading */
  33446. static readonly DELAYLOADSTATE_LOADING: number;
  33447. /** Defines that the ressource is delayed and has not started loading */
  33448. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33449. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33450. static readonly NEVER: number;
  33451. /** 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 */
  33452. static readonly ALWAYS: number;
  33453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33454. static readonly LESS: number;
  33455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33456. static readonly EQUAL: number;
  33457. /** 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 */
  33458. static readonly LEQUAL: number;
  33459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33460. static readonly GREATER: number;
  33461. /** 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 */
  33462. static readonly GEQUAL: number;
  33463. /** 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 */
  33464. static readonly NOTEQUAL: number;
  33465. /** Passed to stencilOperation to specify that stencil value must be kept */
  33466. static readonly KEEP: number;
  33467. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33468. static readonly REPLACE: number;
  33469. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33470. static readonly INCR: number;
  33471. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33472. static readonly DECR: number;
  33473. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33474. static readonly INVERT: number;
  33475. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33476. static readonly INCR_WRAP: number;
  33477. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33478. static readonly DECR_WRAP: number;
  33479. /** Texture is not repeating outside of 0..1 UVs */
  33480. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33481. /** Texture is repeating outside of 0..1 UVs */
  33482. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33483. /** Texture is repeating and mirrored */
  33484. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33485. /** ALPHA */
  33486. static readonly TEXTUREFORMAT_ALPHA: number;
  33487. /** LUMINANCE */
  33488. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33489. /** LUMINANCE_ALPHA */
  33490. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33491. /** RGB */
  33492. static readonly TEXTUREFORMAT_RGB: number;
  33493. /** RGBA */
  33494. static readonly TEXTUREFORMAT_RGBA: number;
  33495. /** RED */
  33496. static readonly TEXTUREFORMAT_RED: number;
  33497. /** RED (2nd reference) */
  33498. static readonly TEXTUREFORMAT_R: number;
  33499. /** RG */
  33500. static readonly TEXTUREFORMAT_RG: number;
  33501. /** RED_INTEGER */
  33502. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33503. /** RED_INTEGER (2nd reference) */
  33504. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33505. /** RG_INTEGER */
  33506. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33507. /** RGB_INTEGER */
  33508. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33509. /** RGBA_INTEGER */
  33510. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33511. /** UNSIGNED_BYTE */
  33512. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33513. /** UNSIGNED_BYTE (2nd reference) */
  33514. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33515. /** FLOAT */
  33516. static readonly TEXTURETYPE_FLOAT: number;
  33517. /** HALF_FLOAT */
  33518. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33519. /** BYTE */
  33520. static readonly TEXTURETYPE_BYTE: number;
  33521. /** SHORT */
  33522. static readonly TEXTURETYPE_SHORT: number;
  33523. /** UNSIGNED_SHORT */
  33524. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33525. /** INT */
  33526. static readonly TEXTURETYPE_INT: number;
  33527. /** UNSIGNED_INT */
  33528. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33529. /** UNSIGNED_SHORT_4_4_4_4 */
  33530. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33531. /** UNSIGNED_SHORT_5_5_5_1 */
  33532. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33533. /** UNSIGNED_SHORT_5_6_5 */
  33534. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33535. /** UNSIGNED_INT_2_10_10_10_REV */
  33536. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33537. /** UNSIGNED_INT_24_8 */
  33538. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33539. /** UNSIGNED_INT_10F_11F_11F_REV */
  33540. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33541. /** UNSIGNED_INT_5_9_9_9_REV */
  33542. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33543. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33544. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33545. /** nearest is mag = nearest and min = nearest and mip = linear */
  33546. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33547. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33548. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33549. /** Trilinear is mag = linear and min = linear and mip = linear */
  33550. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33551. /** nearest is mag = nearest and min = nearest and mip = linear */
  33552. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33554. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33555. /** Trilinear is mag = linear and min = linear and mip = linear */
  33556. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33557. /** mag = nearest and min = nearest and mip = nearest */
  33558. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33559. /** mag = nearest and min = linear and mip = nearest */
  33560. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33561. /** mag = nearest and min = linear and mip = linear */
  33562. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33563. /** mag = nearest and min = linear and mip = none */
  33564. static readonly TEXTURE_NEAREST_LINEAR: number;
  33565. /** mag = nearest and min = nearest and mip = none */
  33566. static readonly TEXTURE_NEAREST_NEAREST: number;
  33567. /** mag = linear and min = nearest and mip = nearest */
  33568. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33569. /** mag = linear and min = nearest and mip = linear */
  33570. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33571. /** mag = linear and min = linear and mip = none */
  33572. static readonly TEXTURE_LINEAR_LINEAR: number;
  33573. /** mag = linear and min = nearest and mip = none */
  33574. static readonly TEXTURE_LINEAR_NEAREST: number;
  33575. /** Explicit coordinates mode */
  33576. static readonly TEXTURE_EXPLICIT_MODE: number;
  33577. /** Spherical coordinates mode */
  33578. static readonly TEXTURE_SPHERICAL_MODE: number;
  33579. /** Planar coordinates mode */
  33580. static readonly TEXTURE_PLANAR_MODE: number;
  33581. /** Cubic coordinates mode */
  33582. static readonly TEXTURE_CUBIC_MODE: number;
  33583. /** Projection coordinates mode */
  33584. static readonly TEXTURE_PROJECTION_MODE: number;
  33585. /** Skybox coordinates mode */
  33586. static readonly TEXTURE_SKYBOX_MODE: number;
  33587. /** Inverse Cubic coordinates mode */
  33588. static readonly TEXTURE_INVCUBIC_MODE: number;
  33589. /** Equirectangular coordinates mode */
  33590. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33591. /** Equirectangular Fixed coordinates mode */
  33592. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33593. /** Equirectangular Fixed Mirrored coordinates mode */
  33594. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33595. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33596. static readonly SCALEMODE_FLOOR: number;
  33597. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33598. static readonly SCALEMODE_NEAREST: number;
  33599. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33600. static readonly SCALEMODE_CEILING: number;
  33601. /**
  33602. * Returns the current npm package of the sdk
  33603. */
  33604. static get NpmPackage(): string;
  33605. /**
  33606. * Returns the current version of the framework
  33607. */
  33608. static get Version(): string;
  33609. /** Gets the list of created engines */
  33610. static get Instances(): Engine[];
  33611. /**
  33612. * Gets the latest created engine
  33613. */
  33614. static get LastCreatedEngine(): Nullable<Engine>;
  33615. /**
  33616. * Gets the latest created scene
  33617. */
  33618. static get LastCreatedScene(): Nullable<Scene>;
  33619. /**
  33620. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33621. * @param flag defines which part of the materials must be marked as dirty
  33622. * @param predicate defines a predicate used to filter which materials should be affected
  33623. */
  33624. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33625. /**
  33626. * Method called to create the default loading screen.
  33627. * This can be overriden in your own app.
  33628. * @param canvas The rendering canvas element
  33629. * @returns The loading screen
  33630. */
  33631. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33632. /**
  33633. * Method called to create the default rescale post process on each engine.
  33634. */
  33635. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33636. /**
  33637. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33638. **/
  33639. enableOfflineSupport: boolean;
  33640. /**
  33641. * 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)
  33642. **/
  33643. disableManifestCheck: boolean;
  33644. /**
  33645. * Gets the list of created scenes
  33646. */
  33647. scenes: Scene[];
  33648. /**
  33649. * Event raised when a new scene is created
  33650. */
  33651. onNewSceneAddedObservable: Observable<Scene>;
  33652. /**
  33653. * Gets the list of created postprocesses
  33654. */
  33655. postProcesses: PostProcess[];
  33656. /**
  33657. * Gets a boolean indicating if the pointer is currently locked
  33658. */
  33659. isPointerLock: boolean;
  33660. /**
  33661. * Observable event triggered each time the rendering canvas is resized
  33662. */
  33663. onResizeObservable: Observable<Engine>;
  33664. /**
  33665. * Observable event triggered each time the canvas loses focus
  33666. */
  33667. onCanvasBlurObservable: Observable<Engine>;
  33668. /**
  33669. * Observable event triggered each time the canvas gains focus
  33670. */
  33671. onCanvasFocusObservable: Observable<Engine>;
  33672. /**
  33673. * Observable event triggered each time the canvas receives pointerout event
  33674. */
  33675. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33676. /**
  33677. * Observable raised when the engine begins a new frame
  33678. */
  33679. onBeginFrameObservable: Observable<Engine>;
  33680. /**
  33681. * If set, will be used to request the next animation frame for the render loop
  33682. */
  33683. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33684. /**
  33685. * Observable raised when the engine ends the current frame
  33686. */
  33687. onEndFrameObservable: Observable<Engine>;
  33688. /**
  33689. * Observable raised when the engine is about to compile a shader
  33690. */
  33691. onBeforeShaderCompilationObservable: Observable<Engine>;
  33692. /**
  33693. * Observable raised when the engine has jsut compiled a shader
  33694. */
  33695. onAfterShaderCompilationObservable: Observable<Engine>;
  33696. /**
  33697. * Gets the audio engine
  33698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33699. * @ignorenaming
  33700. */
  33701. static audioEngine: IAudioEngine;
  33702. /**
  33703. * Default AudioEngine factory responsible of creating the Audio Engine.
  33704. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33705. */
  33706. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33707. /**
  33708. * Default offline support factory responsible of creating a tool used to store data locally.
  33709. * By default, this will create a Database object if the workload has been embedded.
  33710. */
  33711. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33712. private _loadingScreen;
  33713. private _pointerLockRequested;
  33714. private _dummyFramebuffer;
  33715. private _rescalePostProcess;
  33716. private _deterministicLockstep;
  33717. private _lockstepMaxSteps;
  33718. private _timeStep;
  33719. protected get _supportsHardwareTextureRescaling(): boolean;
  33720. private _fps;
  33721. private _deltaTime;
  33722. /** @hidden */
  33723. _drawCalls: PerfCounter;
  33724. /** 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 */
  33725. canvasTabIndex: number;
  33726. /**
  33727. * Turn this value on if you want to pause FPS computation when in background
  33728. */
  33729. disablePerformanceMonitorInBackground: boolean;
  33730. private _performanceMonitor;
  33731. /**
  33732. * Gets the performance monitor attached to this engine
  33733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33734. */
  33735. get performanceMonitor(): PerformanceMonitor;
  33736. private _onFocus;
  33737. private _onBlur;
  33738. private _onCanvasPointerOut;
  33739. private _onCanvasBlur;
  33740. private _onCanvasFocus;
  33741. private _onFullscreenChange;
  33742. private _onPointerLockChange;
  33743. /**
  33744. * Gets the HTML element used to attach event listeners
  33745. * @returns a HTML element
  33746. */
  33747. getInputElement(): Nullable<HTMLElement>;
  33748. /**
  33749. * Creates a new engine
  33750. * @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
  33751. * @param antialias defines enable antialiasing (default: false)
  33752. * @param options defines further options to be sent to the getContext() function
  33753. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33754. */
  33755. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33756. /**
  33757. * Gets current aspect ratio
  33758. * @param viewportOwner defines the camera to use to get the aspect ratio
  33759. * @param useScreen defines if screen size must be used (or the current render target if any)
  33760. * @returns a number defining the aspect ratio
  33761. */
  33762. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33763. /**
  33764. * Gets current screen aspect ratio
  33765. * @returns a number defining the aspect ratio
  33766. */
  33767. getScreenAspectRatio(): number;
  33768. /**
  33769. * Gets the client rect of the HTML canvas attached with the current webGL context
  33770. * @returns a client rectanglee
  33771. */
  33772. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33773. /**
  33774. * Gets the client rect of the HTML element used for events
  33775. * @returns a client rectanglee
  33776. */
  33777. getInputElementClientRect(): Nullable<ClientRect>;
  33778. /**
  33779. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33780. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33781. * @returns true if engine is in deterministic lock step mode
  33782. */
  33783. isDeterministicLockStep(): boolean;
  33784. /**
  33785. * Gets the max steps when engine is running in deterministic lock step
  33786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33787. * @returns the max steps
  33788. */
  33789. getLockstepMaxSteps(): number;
  33790. /**
  33791. * Returns the time in ms between steps when using deterministic lock step.
  33792. * @returns time step in (ms)
  33793. */
  33794. getTimeStep(): number;
  33795. /**
  33796. * Force the mipmap generation for the given render target texture
  33797. * @param texture defines the render target texture to use
  33798. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33799. */
  33800. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33801. /** States */
  33802. /**
  33803. * Set various states to the webGL context
  33804. * @param culling defines backface culling state
  33805. * @param zOffset defines the value to apply to zOffset (0 by default)
  33806. * @param force defines if states must be applied even if cache is up to date
  33807. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33808. */
  33809. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33810. /**
  33811. * Set the z offset to apply to current rendering
  33812. * @param value defines the offset to apply
  33813. */
  33814. setZOffset(value: number): void;
  33815. /**
  33816. * Gets the current value of the zOffset
  33817. * @returns the current zOffset state
  33818. */
  33819. getZOffset(): number;
  33820. /**
  33821. * Enable or disable depth buffering
  33822. * @param enable defines the state to set
  33823. */
  33824. setDepthBuffer(enable: boolean): void;
  33825. /**
  33826. * Gets a boolean indicating if depth writing is enabled
  33827. * @returns the current depth writing state
  33828. */
  33829. getDepthWrite(): boolean;
  33830. /**
  33831. * Enable or disable depth writing
  33832. * @param enable defines the state to set
  33833. */
  33834. setDepthWrite(enable: boolean): void;
  33835. /**
  33836. * Gets a boolean indicating if stencil buffer is enabled
  33837. * @returns the current stencil buffer state
  33838. */
  33839. getStencilBuffer(): boolean;
  33840. /**
  33841. * Enable or disable the stencil buffer
  33842. * @param enable defines if the stencil buffer must be enabled or disabled
  33843. */
  33844. setStencilBuffer(enable: boolean): void;
  33845. /**
  33846. * Gets the current stencil mask
  33847. * @returns a number defining the new stencil mask to use
  33848. */
  33849. getStencilMask(): number;
  33850. /**
  33851. * Sets the current stencil mask
  33852. * @param mask defines the new stencil mask to use
  33853. */
  33854. setStencilMask(mask: number): void;
  33855. /**
  33856. * Gets the current stencil function
  33857. * @returns a number defining the stencil function to use
  33858. */
  33859. getStencilFunction(): number;
  33860. /**
  33861. * Gets the current stencil reference value
  33862. * @returns a number defining the stencil reference value to use
  33863. */
  33864. getStencilFunctionReference(): number;
  33865. /**
  33866. * Gets the current stencil mask
  33867. * @returns a number defining the stencil mask to use
  33868. */
  33869. getStencilFunctionMask(): number;
  33870. /**
  33871. * Sets the current stencil function
  33872. * @param stencilFunc defines the new stencil function to use
  33873. */
  33874. setStencilFunction(stencilFunc: number): void;
  33875. /**
  33876. * Sets the current stencil reference
  33877. * @param reference defines the new stencil reference to use
  33878. */
  33879. setStencilFunctionReference(reference: number): void;
  33880. /**
  33881. * Sets the current stencil mask
  33882. * @param mask defines the new stencil mask to use
  33883. */
  33884. setStencilFunctionMask(mask: number): void;
  33885. /**
  33886. * Gets the current stencil operation when stencil fails
  33887. * @returns a number defining stencil operation to use when stencil fails
  33888. */
  33889. getStencilOperationFail(): number;
  33890. /**
  33891. * Gets the current stencil operation when depth fails
  33892. * @returns a number defining stencil operation to use when depth fails
  33893. */
  33894. getStencilOperationDepthFail(): number;
  33895. /**
  33896. * Gets the current stencil operation when stencil passes
  33897. * @returns a number defining stencil operation to use when stencil passes
  33898. */
  33899. getStencilOperationPass(): number;
  33900. /**
  33901. * Sets the stencil operation to use when stencil fails
  33902. * @param operation defines the stencil operation to use when stencil fails
  33903. */
  33904. setStencilOperationFail(operation: number): void;
  33905. /**
  33906. * Sets the stencil operation to use when depth fails
  33907. * @param operation defines the stencil operation to use when depth fails
  33908. */
  33909. setStencilOperationDepthFail(operation: number): void;
  33910. /**
  33911. * Sets the stencil operation to use when stencil passes
  33912. * @param operation defines the stencil operation to use when stencil passes
  33913. */
  33914. setStencilOperationPass(operation: number): void;
  33915. /**
  33916. * Sets a boolean indicating if the dithering state is enabled or disabled
  33917. * @param value defines the dithering state
  33918. */
  33919. setDitheringState(value: boolean): void;
  33920. /**
  33921. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33922. * @param value defines the rasterizer state
  33923. */
  33924. setRasterizerState(value: boolean): void;
  33925. /**
  33926. * Gets the current depth function
  33927. * @returns a number defining the depth function
  33928. */
  33929. getDepthFunction(): Nullable<number>;
  33930. /**
  33931. * Sets the current depth function
  33932. * @param depthFunc defines the function to use
  33933. */
  33934. setDepthFunction(depthFunc: number): void;
  33935. /**
  33936. * Sets the current depth function to GREATER
  33937. */
  33938. setDepthFunctionToGreater(): void;
  33939. /**
  33940. * Sets the current depth function to GEQUAL
  33941. */
  33942. setDepthFunctionToGreaterOrEqual(): void;
  33943. /**
  33944. * Sets the current depth function to LESS
  33945. */
  33946. setDepthFunctionToLess(): void;
  33947. /**
  33948. * Sets the current depth function to LEQUAL
  33949. */
  33950. setDepthFunctionToLessOrEqual(): void;
  33951. private _cachedStencilBuffer;
  33952. private _cachedStencilFunction;
  33953. private _cachedStencilMask;
  33954. private _cachedStencilOperationPass;
  33955. private _cachedStencilOperationFail;
  33956. private _cachedStencilOperationDepthFail;
  33957. private _cachedStencilReference;
  33958. /**
  33959. * Caches the the state of the stencil buffer
  33960. */
  33961. cacheStencilState(): void;
  33962. /**
  33963. * Restores the state of the stencil buffer
  33964. */
  33965. restoreStencilState(): void;
  33966. /**
  33967. * Directly set the WebGL Viewport
  33968. * @param x defines the x coordinate of the viewport (in screen space)
  33969. * @param y defines the y coordinate of the viewport (in screen space)
  33970. * @param width defines the width of the viewport (in screen space)
  33971. * @param height defines the height of the viewport (in screen space)
  33972. * @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
  33973. */
  33974. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33975. /**
  33976. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33977. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33978. * @param y defines the y-coordinate of the corner of the clear rectangle
  33979. * @param width defines the width of the clear rectangle
  33980. * @param height defines the height of the clear rectangle
  33981. * @param clearColor defines the clear color
  33982. */
  33983. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33984. /**
  33985. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33986. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33987. * @param y defines the y-coordinate of the corner of the clear rectangle
  33988. * @param width defines the width of the clear rectangle
  33989. * @param height defines the height of the clear rectangle
  33990. */
  33991. enableScissor(x: number, y: number, width: number, height: number): void;
  33992. /**
  33993. * Disable previously set scissor test rectangle
  33994. */
  33995. disableScissor(): void;
  33996. protected _reportDrawCall(): void;
  33997. /**
  33998. * Initializes a webVR display and starts listening to display change events
  33999. * The onVRDisplayChangedObservable will be notified upon these changes
  34000. * @returns The onVRDisplayChangedObservable
  34001. */
  34002. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34003. /** @hidden */
  34004. _prepareVRComponent(): void;
  34005. /** @hidden */
  34006. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34007. /** @hidden */
  34008. _submitVRFrame(): void;
  34009. /**
  34010. * Call this function to leave webVR mode
  34011. * Will do nothing if webVR is not supported or if there is no webVR device
  34012. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34013. */
  34014. disableVR(): void;
  34015. /**
  34016. * Gets a boolean indicating that the system is in VR mode and is presenting
  34017. * @returns true if VR mode is engaged
  34018. */
  34019. isVRPresenting(): boolean;
  34020. /** @hidden */
  34021. _requestVRFrame(): void;
  34022. /** @hidden */
  34023. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34024. /**
  34025. * Gets the source code of the vertex shader associated with a specific webGL program
  34026. * @param program defines the program to use
  34027. * @returns a string containing the source code of the vertex shader associated with the program
  34028. */
  34029. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34030. /**
  34031. * Gets the source code of the fragment shader associated with a specific webGL program
  34032. * @param program defines the program to use
  34033. * @returns a string containing the source code of the fragment shader associated with the program
  34034. */
  34035. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34036. /**
  34037. * Sets a depth stencil texture from a render target to the according uniform.
  34038. * @param channel The texture channel
  34039. * @param uniform The uniform to set
  34040. * @param texture The render target texture containing the depth stencil texture to apply
  34041. */
  34042. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34043. /**
  34044. * Sets a texture to the webGL context from a postprocess
  34045. * @param channel defines the channel to use
  34046. * @param postProcess defines the source postprocess
  34047. */
  34048. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34049. /**
  34050. * Binds the output of the passed in post process to the texture channel specified
  34051. * @param channel The channel the texture should be bound to
  34052. * @param postProcess The post process which's output should be bound
  34053. */
  34054. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34055. /** @hidden */
  34056. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34057. protected _rebuildBuffers(): void;
  34058. /** @hidden */
  34059. _renderFrame(): void;
  34060. _renderLoop(): void;
  34061. /** @hidden */
  34062. _renderViews(): boolean;
  34063. /**
  34064. * Toggle full screen mode
  34065. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34066. */
  34067. switchFullscreen(requestPointerLock: boolean): void;
  34068. /**
  34069. * Enters full screen mode
  34070. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34071. */
  34072. enterFullscreen(requestPointerLock: boolean): void;
  34073. /**
  34074. * Exits full screen mode
  34075. */
  34076. exitFullscreen(): void;
  34077. /**
  34078. * Enters Pointerlock mode
  34079. */
  34080. enterPointerlock(): void;
  34081. /**
  34082. * Exits Pointerlock mode
  34083. */
  34084. exitPointerlock(): void;
  34085. /**
  34086. * Begin a new frame
  34087. */
  34088. beginFrame(): void;
  34089. /**
  34090. * Enf the current frame
  34091. */
  34092. endFrame(): void;
  34093. resize(): void;
  34094. /**
  34095. * Force a specific size of the canvas
  34096. * @param width defines the new canvas' width
  34097. * @param height defines the new canvas' height
  34098. */
  34099. setSize(width: number, height: number): void;
  34100. /**
  34101. * Updates a dynamic vertex buffer.
  34102. * @param vertexBuffer the vertex buffer to update
  34103. * @param data the data used to update the vertex buffer
  34104. * @param byteOffset the byte offset of the data
  34105. * @param byteLength the byte length of the data
  34106. */
  34107. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34108. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34109. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34110. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34111. _releaseTexture(texture: InternalTexture): void;
  34112. /**
  34113. * @hidden
  34114. * Rescales a texture
  34115. * @param source input texutre
  34116. * @param destination destination texture
  34117. * @param scene scene to use to render the resize
  34118. * @param internalFormat format to use when resizing
  34119. * @param onComplete callback to be called when resize has completed
  34120. */
  34121. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34122. /**
  34123. * Gets the current framerate
  34124. * @returns a number representing the framerate
  34125. */
  34126. getFps(): number;
  34127. /**
  34128. * Gets the time spent between current and previous frame
  34129. * @returns a number representing the delta time in ms
  34130. */
  34131. getDeltaTime(): number;
  34132. private _measureFps;
  34133. /** @hidden */
  34134. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34135. /**
  34136. * Update a dynamic index buffer
  34137. * @param indexBuffer defines the target index buffer
  34138. * @param indices defines the data to update
  34139. * @param offset defines the offset in the target index buffer where update should start
  34140. */
  34141. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34142. /**
  34143. * Updates the sample count of a render target texture
  34144. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34145. * @param texture defines the texture to update
  34146. * @param samples defines the sample count to set
  34147. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34148. */
  34149. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34150. /**
  34151. * Updates a depth texture Comparison Mode and Function.
  34152. * If the comparison Function is equal to 0, the mode will be set to none.
  34153. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34154. * @param texture The texture to set the comparison function for
  34155. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34156. */
  34157. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34158. /**
  34159. * Creates a webGL buffer to use with instanciation
  34160. * @param capacity defines the size of the buffer
  34161. * @returns the webGL buffer
  34162. */
  34163. createInstancesBuffer(capacity: number): DataBuffer;
  34164. /**
  34165. * Delete a webGL buffer used with instanciation
  34166. * @param buffer defines the webGL buffer to delete
  34167. */
  34168. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34169. private _clientWaitAsync;
  34170. /** @hidden */
  34171. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34172. /** @hidden */
  34173. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34174. dispose(): void;
  34175. private _disableTouchAction;
  34176. /**
  34177. * Display the loading screen
  34178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34179. */
  34180. displayLoadingUI(): void;
  34181. /**
  34182. * Hide the loading screen
  34183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34184. */
  34185. hideLoadingUI(): void;
  34186. /**
  34187. * Gets the current loading screen object
  34188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34189. */
  34190. get loadingScreen(): ILoadingScreen;
  34191. /**
  34192. * Sets the current loading screen object
  34193. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34194. */
  34195. set loadingScreen(loadingScreen: ILoadingScreen);
  34196. /**
  34197. * Sets the current loading screen text
  34198. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34199. */
  34200. set loadingUIText(text: string);
  34201. /**
  34202. * Sets the current loading screen background color
  34203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34204. */
  34205. set loadingUIBackgroundColor(color: string);
  34206. /** Pointerlock and fullscreen */
  34207. /**
  34208. * Ask the browser to promote the current element to pointerlock mode
  34209. * @param element defines the DOM element to promote
  34210. */
  34211. static _RequestPointerlock(element: HTMLElement): void;
  34212. /**
  34213. * Asks the browser to exit pointerlock mode
  34214. */
  34215. static _ExitPointerlock(): void;
  34216. /**
  34217. * Ask the browser to promote the current element to fullscreen rendering mode
  34218. * @param element defines the DOM element to promote
  34219. */
  34220. static _RequestFullscreen(element: HTMLElement): void;
  34221. /**
  34222. * Asks the browser to exit fullscreen mode
  34223. */
  34224. static _ExitFullscreen(): void;
  34225. }
  34226. }
  34227. declare module BABYLON {
  34228. /**
  34229. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34230. * during the life time of the application.
  34231. */
  34232. export class EngineStore {
  34233. /** Gets the list of created engines */
  34234. static Instances: Engine[];
  34235. /** @hidden */
  34236. static _LastCreatedScene: Nullable<Scene>;
  34237. /**
  34238. * Gets the latest created engine
  34239. */
  34240. static get LastCreatedEngine(): Nullable<Engine>;
  34241. /**
  34242. * Gets the latest created scene
  34243. */
  34244. static get LastCreatedScene(): Nullable<Scene>;
  34245. /**
  34246. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34247. * @ignorenaming
  34248. */
  34249. static UseFallbackTexture: boolean;
  34250. /**
  34251. * Texture content used if a texture cannot loaded
  34252. * @ignorenaming
  34253. */
  34254. static FallbackTexture: string;
  34255. }
  34256. }
  34257. declare module BABYLON {
  34258. /**
  34259. * Helper class that provides a small promise polyfill
  34260. */
  34261. export class PromisePolyfill {
  34262. /**
  34263. * Static function used to check if the polyfill is required
  34264. * If this is the case then the function will inject the polyfill to window.Promise
  34265. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34266. */
  34267. static Apply(force?: boolean): void;
  34268. }
  34269. }
  34270. declare module BABYLON {
  34271. /**
  34272. * Interface for screenshot methods with describe argument called `size` as object with options
  34273. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34274. */
  34275. export interface IScreenshotSize {
  34276. /**
  34277. * number in pixels for canvas height
  34278. */
  34279. height?: number;
  34280. /**
  34281. * multiplier allowing render at a higher or lower resolution
  34282. * If value is defined then height and width will be ignored and taken from camera
  34283. */
  34284. precision?: number;
  34285. /**
  34286. * number in pixels for canvas width
  34287. */
  34288. width?: number;
  34289. }
  34290. }
  34291. declare module BABYLON {
  34292. interface IColor4Like {
  34293. r: float;
  34294. g: float;
  34295. b: float;
  34296. a: float;
  34297. }
  34298. /**
  34299. * Class containing a set of static utilities functions
  34300. */
  34301. export class Tools {
  34302. /**
  34303. * Gets or sets the base URL to use to load assets
  34304. */
  34305. static get BaseUrl(): string;
  34306. static set BaseUrl(value: string);
  34307. /**
  34308. * Enable/Disable Custom HTTP Request Headers globally.
  34309. * default = false
  34310. * @see CustomRequestHeaders
  34311. */
  34312. static UseCustomRequestHeaders: boolean;
  34313. /**
  34314. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34315. * i.e. when loading files, where the server/service expects an Authorization header
  34316. */
  34317. static CustomRequestHeaders: {
  34318. [key: string]: string;
  34319. };
  34320. /**
  34321. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34322. */
  34323. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34324. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34325. /**
  34326. * Default behaviour for cors in the application.
  34327. * It can be a string if the expected behavior is identical in the entire app.
  34328. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34329. */
  34330. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34331. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34332. /**
  34333. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34334. * @ignorenaming
  34335. */
  34336. static get UseFallbackTexture(): boolean;
  34337. static set UseFallbackTexture(value: boolean);
  34338. /**
  34339. * Use this object to register external classes like custom textures or material
  34340. * to allow the laoders to instantiate them
  34341. */
  34342. static get RegisteredExternalClasses(): {
  34343. [key: string]: Object;
  34344. };
  34345. static set RegisteredExternalClasses(classes: {
  34346. [key: string]: Object;
  34347. });
  34348. /**
  34349. * Texture content used if a texture cannot loaded
  34350. * @ignorenaming
  34351. */
  34352. static get fallbackTexture(): string;
  34353. static set fallbackTexture(value: string);
  34354. /**
  34355. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34356. * @param u defines the coordinate on X axis
  34357. * @param v defines the coordinate on Y axis
  34358. * @param width defines the width of the source data
  34359. * @param height defines the height of the source data
  34360. * @param pixels defines the source byte array
  34361. * @param color defines the output color
  34362. */
  34363. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34364. /**
  34365. * Interpolates between a and b via alpha
  34366. * @param a The lower value (returned when alpha = 0)
  34367. * @param b The upper value (returned when alpha = 1)
  34368. * @param alpha The interpolation-factor
  34369. * @return The mixed value
  34370. */
  34371. static Mix(a: number, b: number, alpha: number): number;
  34372. /**
  34373. * Tries to instantiate a new object from a given class name
  34374. * @param className defines the class name to instantiate
  34375. * @returns the new object or null if the system was not able to do the instantiation
  34376. */
  34377. static Instantiate(className: string): any;
  34378. /**
  34379. * Provides a slice function that will work even on IE
  34380. * @param data defines the array to slice
  34381. * @param start defines the start of the data (optional)
  34382. * @param end defines the end of the data (optional)
  34383. * @returns the new sliced array
  34384. */
  34385. static Slice<T>(data: T, start?: number, end?: number): T;
  34386. /**
  34387. * Polyfill for setImmediate
  34388. * @param action defines the action to execute after the current execution block
  34389. */
  34390. static SetImmediate(action: () => void): void;
  34391. /**
  34392. * Function indicating if a number is an exponent of 2
  34393. * @param value defines the value to test
  34394. * @returns true if the value is an exponent of 2
  34395. */
  34396. static IsExponentOfTwo(value: number): boolean;
  34397. private static _tmpFloatArray;
  34398. /**
  34399. * Returns the nearest 32-bit single precision float representation of a Number
  34400. * @param value A Number. If the parameter is of a different type, it will get converted
  34401. * to a number or to NaN if it cannot be converted
  34402. * @returns number
  34403. */
  34404. static FloatRound(value: number): number;
  34405. /**
  34406. * Extracts the filename from a path
  34407. * @param path defines the path to use
  34408. * @returns the filename
  34409. */
  34410. static GetFilename(path: string): string;
  34411. /**
  34412. * Extracts the "folder" part of a path (everything before the filename).
  34413. * @param uri The URI to extract the info from
  34414. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34415. * @returns The "folder" part of the path
  34416. */
  34417. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34418. /**
  34419. * Extracts text content from a DOM element hierarchy
  34420. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34421. */
  34422. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34423. /**
  34424. * Convert an angle in radians to degrees
  34425. * @param angle defines the angle to convert
  34426. * @returns the angle in degrees
  34427. */
  34428. static ToDegrees(angle: number): number;
  34429. /**
  34430. * Convert an angle in degrees to radians
  34431. * @param angle defines the angle to convert
  34432. * @returns the angle in radians
  34433. */
  34434. static ToRadians(angle: number): number;
  34435. /**
  34436. * Returns an array if obj is not an array
  34437. * @param obj defines the object to evaluate as an array
  34438. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34439. * @returns either obj directly if obj is an array or a new array containing obj
  34440. */
  34441. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34442. /**
  34443. * Gets the pointer prefix to use
  34444. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34445. */
  34446. static GetPointerPrefix(): string;
  34447. /**
  34448. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34449. * @param url define the url we are trying
  34450. * @param element define the dom element where to configure the cors policy
  34451. */
  34452. static SetCorsBehavior(url: string | string[], element: {
  34453. crossOrigin: string | null;
  34454. }): void;
  34455. /**
  34456. * Removes unwanted characters from an url
  34457. * @param url defines the url to clean
  34458. * @returns the cleaned url
  34459. */
  34460. static CleanUrl(url: string): string;
  34461. /**
  34462. * Gets or sets a function used to pre-process url before using them to load assets
  34463. */
  34464. static get PreprocessUrl(): (url: string) => string;
  34465. static set PreprocessUrl(processor: (url: string) => string);
  34466. /**
  34467. * Loads an image as an HTMLImageElement.
  34468. * @param input url string, ArrayBuffer, or Blob to load
  34469. * @param onLoad callback called when the image successfully loads
  34470. * @param onError callback called when the image fails to load
  34471. * @param offlineProvider offline provider for caching
  34472. * @param mimeType optional mime type
  34473. * @returns the HTMLImageElement of the loaded image
  34474. */
  34475. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34476. /**
  34477. * Loads a file from a url
  34478. * @param url url string, ArrayBuffer, or Blob to load
  34479. * @param onSuccess callback called when the file successfully loads
  34480. * @param onProgress callback called while file is loading (if the server supports this mode)
  34481. * @param offlineProvider defines the offline provider for caching
  34482. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34483. * @param onError callback called when the file fails to load
  34484. * @returns a file request object
  34485. */
  34486. 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;
  34487. /**
  34488. * Loads a file from a url
  34489. * @param url the file url to load
  34490. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34491. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34492. */
  34493. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34494. /**
  34495. * Load a script (identified by an url). When the url returns, the
  34496. * content of this file is added into a new script element, attached to the DOM (body element)
  34497. * @param scriptUrl defines the url of the script to laod
  34498. * @param onSuccess defines the callback called when the script is loaded
  34499. * @param onError defines the callback to call if an error occurs
  34500. * @param scriptId defines the id of the script element
  34501. */
  34502. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34503. /**
  34504. * Load an asynchronous script (identified by an url). When the url returns, the
  34505. * content of this file is added into a new script element, attached to the DOM (body element)
  34506. * @param scriptUrl defines the url of the script to laod
  34507. * @param scriptId defines the id of the script element
  34508. * @returns a promise request object
  34509. */
  34510. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34511. /**
  34512. * Loads a file from a blob
  34513. * @param fileToLoad defines the blob to use
  34514. * @param callback defines the callback to call when data is loaded
  34515. * @param progressCallback defines the callback to call during loading process
  34516. * @returns a file request object
  34517. */
  34518. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34519. /**
  34520. * Reads a file from a File object
  34521. * @param file defines the file to load
  34522. * @param onSuccess defines the callback to call when data is loaded
  34523. * @param onProgress defines the callback to call during loading process
  34524. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34525. * @param onError defines the callback to call when an error occurs
  34526. * @returns a file request object
  34527. */
  34528. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34529. /**
  34530. * Creates a data url from a given string content
  34531. * @param content defines the content to convert
  34532. * @returns the new data url link
  34533. */
  34534. static FileAsURL(content: string): string;
  34535. /**
  34536. * Format the given number to a specific decimal format
  34537. * @param value defines the number to format
  34538. * @param decimals defines the number of decimals to use
  34539. * @returns the formatted string
  34540. */
  34541. static Format(value: number, decimals?: number): string;
  34542. /**
  34543. * Tries to copy an object by duplicating every property
  34544. * @param source defines the source object
  34545. * @param destination defines the target object
  34546. * @param doNotCopyList defines a list of properties to avoid
  34547. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34548. */
  34549. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34550. /**
  34551. * Gets a boolean indicating if the given object has no own property
  34552. * @param obj defines the object to test
  34553. * @returns true if object has no own property
  34554. */
  34555. static IsEmpty(obj: any): boolean;
  34556. /**
  34557. * Function used to register events at window level
  34558. * @param windowElement defines the Window object to use
  34559. * @param events defines the events to register
  34560. */
  34561. static RegisterTopRootEvents(windowElement: Window, events: {
  34562. name: string;
  34563. handler: Nullable<(e: FocusEvent) => any>;
  34564. }[]): void;
  34565. /**
  34566. * Function used to unregister events from window level
  34567. * @param windowElement defines the Window object to use
  34568. * @param events defines the events to unregister
  34569. */
  34570. static UnregisterTopRootEvents(windowElement: Window, events: {
  34571. name: string;
  34572. handler: Nullable<(e: FocusEvent) => any>;
  34573. }[]): void;
  34574. /**
  34575. * @ignore
  34576. */
  34577. static _ScreenshotCanvas: HTMLCanvasElement;
  34578. /**
  34579. * Dumps the current bound framebuffer
  34580. * @param width defines the rendering width
  34581. * @param height defines the rendering height
  34582. * @param engine defines the hosting engine
  34583. * @param successCallback defines the callback triggered once the data are available
  34584. * @param mimeType defines the mime type of the result
  34585. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34586. */
  34587. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34588. /**
  34589. * Converts the canvas data to blob.
  34590. * This acts as a polyfill for browsers not supporting the to blob function.
  34591. * @param canvas Defines the canvas to extract the data from
  34592. * @param successCallback Defines the callback triggered once the data are available
  34593. * @param mimeType Defines the mime type of the result
  34594. */
  34595. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34596. /**
  34597. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34598. * @param successCallback defines the callback triggered once the data are available
  34599. * @param mimeType defines the mime type of the result
  34600. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34601. */
  34602. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34603. /**
  34604. * Downloads a blob in the browser
  34605. * @param blob defines the blob to download
  34606. * @param fileName defines the name of the downloaded file
  34607. */
  34608. static Download(blob: Blob, fileName: string): void;
  34609. /**
  34610. * Captures a screenshot of the current rendering
  34611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34612. * @param engine defines the rendering engine
  34613. * @param camera defines the source camera
  34614. * @param size This parameter can be set to a single number or to an object with the
  34615. * following (optional) properties: precision, width, height. If a single number is passed,
  34616. * it will be used for both width and height. If an object is passed, the screenshot size
  34617. * will be derived from the parameters. The precision property is a multiplier allowing
  34618. * rendering at a higher or lower resolution
  34619. * @param successCallback defines the callback receives a single parameter which contains the
  34620. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34621. * src parameter of an <img> to display it
  34622. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34623. * Check your browser for supported MIME types
  34624. */
  34625. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34626. /**
  34627. * Captures a screenshot of the current rendering
  34628. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34629. * @param engine defines the rendering engine
  34630. * @param camera defines the source camera
  34631. * @param size This parameter can be set to a single number or to an object with the
  34632. * following (optional) properties: precision, width, height. If a single number is passed,
  34633. * it will be used for both width and height. If an object is passed, the screenshot size
  34634. * will be derived from the parameters. The precision property is a multiplier allowing
  34635. * rendering at a higher or lower resolution
  34636. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34637. * Check your browser for supported MIME types
  34638. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34639. * to the src parameter of an <img> to display it
  34640. */
  34641. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34642. /**
  34643. * Generates an image screenshot from the specified camera.
  34644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34645. * @param engine The engine to use for rendering
  34646. * @param camera The camera to use for rendering
  34647. * @param size This parameter can be set to a single number or to an object with the
  34648. * following (optional) properties: precision, width, height. If a single number is passed,
  34649. * it will be used for both width and height. If an object is passed, the screenshot size
  34650. * will be derived from the parameters. The precision property is a multiplier allowing
  34651. * rendering at a higher or lower resolution
  34652. * @param successCallback The callback receives a single parameter which contains the
  34653. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34654. * src parameter of an <img> to display it
  34655. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34656. * Check your browser for supported MIME types
  34657. * @param samples Texture samples (default: 1)
  34658. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34659. * @param fileName A name for for the downloaded file.
  34660. */
  34661. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34662. /**
  34663. * Generates an image screenshot from the specified camera.
  34664. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34665. * @param engine The engine to use for rendering
  34666. * @param camera The camera to use for rendering
  34667. * @param size This parameter can be set to a single number or to an object with the
  34668. * following (optional) properties: precision, width, height. If a single number is passed,
  34669. * it will be used for both width and height. If an object is passed, the screenshot size
  34670. * will be derived from the parameters. The precision property is a multiplier allowing
  34671. * rendering at a higher or lower resolution
  34672. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34673. * Check your browser for supported MIME types
  34674. * @param samples Texture samples (default: 1)
  34675. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34676. * @param fileName A name for for the downloaded file.
  34677. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34678. * to the src parameter of an <img> to display it
  34679. */
  34680. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34681. /**
  34682. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34683. * Be aware Math.random() could cause collisions, but:
  34684. * "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"
  34685. * @returns a pseudo random id
  34686. */
  34687. static RandomId(): string;
  34688. /**
  34689. * Test if the given uri is a base64 string
  34690. * @param uri The uri to test
  34691. * @return True if the uri is a base64 string or false otherwise
  34692. */
  34693. static IsBase64(uri: string): boolean;
  34694. /**
  34695. * Decode the given base64 uri.
  34696. * @param uri The uri to decode
  34697. * @return The decoded base64 data.
  34698. */
  34699. static DecodeBase64(uri: string): ArrayBuffer;
  34700. /**
  34701. * Gets the absolute url.
  34702. * @param url the input url
  34703. * @return the absolute url
  34704. */
  34705. static GetAbsoluteUrl(url: string): string;
  34706. /**
  34707. * No log
  34708. */
  34709. static readonly NoneLogLevel: number;
  34710. /**
  34711. * Only message logs
  34712. */
  34713. static readonly MessageLogLevel: number;
  34714. /**
  34715. * Only warning logs
  34716. */
  34717. static readonly WarningLogLevel: number;
  34718. /**
  34719. * Only error logs
  34720. */
  34721. static readonly ErrorLogLevel: number;
  34722. /**
  34723. * All logs
  34724. */
  34725. static readonly AllLogLevel: number;
  34726. /**
  34727. * Gets a value indicating the number of loading errors
  34728. * @ignorenaming
  34729. */
  34730. static get errorsCount(): number;
  34731. /**
  34732. * Callback called when a new log is added
  34733. */
  34734. static OnNewCacheEntry: (entry: string) => void;
  34735. /**
  34736. * Log a message to the console
  34737. * @param message defines the message to log
  34738. */
  34739. static Log(message: string): void;
  34740. /**
  34741. * Write a warning message to the console
  34742. * @param message defines the message to log
  34743. */
  34744. static Warn(message: string): void;
  34745. /**
  34746. * Write an error message to the console
  34747. * @param message defines the message to log
  34748. */
  34749. static Error(message: string): void;
  34750. /**
  34751. * Gets current log cache (list of logs)
  34752. */
  34753. static get LogCache(): string;
  34754. /**
  34755. * Clears the log cache
  34756. */
  34757. static ClearLogCache(): void;
  34758. /**
  34759. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34760. */
  34761. static set LogLevels(level: number);
  34762. /**
  34763. * Checks if the window object exists
  34764. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34765. */
  34766. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34767. /**
  34768. * No performance log
  34769. */
  34770. static readonly PerformanceNoneLogLevel: number;
  34771. /**
  34772. * Use user marks to log performance
  34773. */
  34774. static readonly PerformanceUserMarkLogLevel: number;
  34775. /**
  34776. * Log performance to the console
  34777. */
  34778. static readonly PerformanceConsoleLogLevel: number;
  34779. private static _performance;
  34780. /**
  34781. * Sets the current performance log level
  34782. */
  34783. static set PerformanceLogLevel(level: number);
  34784. private static _StartPerformanceCounterDisabled;
  34785. private static _EndPerformanceCounterDisabled;
  34786. private static _StartUserMark;
  34787. private static _EndUserMark;
  34788. private static _StartPerformanceConsole;
  34789. private static _EndPerformanceConsole;
  34790. /**
  34791. * Starts a performance counter
  34792. */
  34793. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34794. /**
  34795. * Ends a specific performance coutner
  34796. */
  34797. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34798. /**
  34799. * Gets either window.performance.now() if supported or Date.now() else
  34800. */
  34801. static get Now(): number;
  34802. /**
  34803. * This method will return the name of the class used to create the instance of the given object.
  34804. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34805. * @param object the object to get the class name from
  34806. * @param isType defines if the object is actually a type
  34807. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34808. */
  34809. static GetClassName(object: any, isType?: boolean): string;
  34810. /**
  34811. * Gets the first element of an array satisfying a given predicate
  34812. * @param array defines the array to browse
  34813. * @param predicate defines the predicate to use
  34814. * @returns null if not found or the element
  34815. */
  34816. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34817. /**
  34818. * This method will return the name of the full name of the class, including its owning module (if any).
  34819. * 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).
  34820. * @param object the object to get the class name from
  34821. * @param isType defines if the object is actually a type
  34822. * @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.
  34823. * @ignorenaming
  34824. */
  34825. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34826. /**
  34827. * Returns a promise that resolves after the given amount of time.
  34828. * @param delay Number of milliseconds to delay
  34829. * @returns Promise that resolves after the given amount of time
  34830. */
  34831. static DelayAsync(delay: number): Promise<void>;
  34832. /**
  34833. * Utility function to detect if the current user agent is Safari
  34834. * @returns whether or not the current user agent is safari
  34835. */
  34836. static IsSafari(): boolean;
  34837. }
  34838. /**
  34839. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34840. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34841. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34842. * @param name The name of the class, case should be preserved
  34843. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34844. */
  34845. export function className(name: string, module?: string): (target: Object) => void;
  34846. /**
  34847. * An implementation of a loop for asynchronous functions.
  34848. */
  34849. export class AsyncLoop {
  34850. /**
  34851. * Defines the number of iterations for the loop
  34852. */
  34853. iterations: number;
  34854. /**
  34855. * Defines the current index of the loop.
  34856. */
  34857. index: number;
  34858. private _done;
  34859. private _fn;
  34860. private _successCallback;
  34861. /**
  34862. * Constructor.
  34863. * @param iterations the number of iterations.
  34864. * @param func the function to run each iteration
  34865. * @param successCallback the callback that will be called upon succesful execution
  34866. * @param offset starting offset.
  34867. */
  34868. constructor(
  34869. /**
  34870. * Defines the number of iterations for the loop
  34871. */
  34872. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34873. /**
  34874. * Execute the next iteration. Must be called after the last iteration was finished.
  34875. */
  34876. executeNext(): void;
  34877. /**
  34878. * Break the loop and run the success callback.
  34879. */
  34880. breakLoop(): void;
  34881. /**
  34882. * Create and run an async loop.
  34883. * @param iterations the number of iterations.
  34884. * @param fn the function to run each iteration
  34885. * @param successCallback the callback that will be called upon succesful execution
  34886. * @param offset starting offset.
  34887. * @returns the created async loop object
  34888. */
  34889. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34890. /**
  34891. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34892. * @param iterations total number of iterations
  34893. * @param syncedIterations number of synchronous iterations in each async iteration.
  34894. * @param fn the function to call each iteration.
  34895. * @param callback a success call back that will be called when iterating stops.
  34896. * @param breakFunction a break condition (optional)
  34897. * @param timeout timeout settings for the setTimeout function. default - 0.
  34898. * @returns the created async loop object
  34899. */
  34900. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34901. }
  34902. }
  34903. declare module BABYLON {
  34904. /**
  34905. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34906. * The underlying implementation relies on an associative array to ensure the best performances.
  34907. * The value can be anything including 'null' but except 'undefined'
  34908. */
  34909. export class StringDictionary<T> {
  34910. /**
  34911. * This will clear this dictionary and copy the content from the 'source' one.
  34912. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34913. * @param source the dictionary to take the content from and copy to this dictionary
  34914. */
  34915. copyFrom(source: StringDictionary<T>): void;
  34916. /**
  34917. * Get a value based from its key
  34918. * @param key the given key to get the matching value from
  34919. * @return the value if found, otherwise undefined is returned
  34920. */
  34921. get(key: string): T | undefined;
  34922. /**
  34923. * Get a value from its key or add it if it doesn't exist.
  34924. * This method will ensure you that a given key/data will be present in the dictionary.
  34925. * @param key the given key to get the matching value from
  34926. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34927. * The factory will only be invoked if there's no data for the given key.
  34928. * @return the value corresponding to the key.
  34929. */
  34930. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34931. /**
  34932. * Get a value from its key if present in the dictionary otherwise add it
  34933. * @param key the key to get the value from
  34934. * @param val if there's no such key/value pair in the dictionary add it with this value
  34935. * @return the value corresponding to the key
  34936. */
  34937. getOrAdd(key: string, val: T): T;
  34938. /**
  34939. * Check if there's a given key in the dictionary
  34940. * @param key the key to check for
  34941. * @return true if the key is present, false otherwise
  34942. */
  34943. contains(key: string): boolean;
  34944. /**
  34945. * Add a new key and its corresponding value
  34946. * @param key the key to add
  34947. * @param value the value corresponding to the key
  34948. * @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
  34949. */
  34950. add(key: string, value: T): boolean;
  34951. /**
  34952. * Update a specific value associated to a key
  34953. * @param key defines the key to use
  34954. * @param value defines the value to store
  34955. * @returns true if the value was updated (or false if the key was not found)
  34956. */
  34957. set(key: string, value: T): boolean;
  34958. /**
  34959. * Get the element of the given key and remove it from the dictionary
  34960. * @param key defines the key to search
  34961. * @returns the value associated with the key or null if not found
  34962. */
  34963. getAndRemove(key: string): Nullable<T>;
  34964. /**
  34965. * Remove a key/value from the dictionary.
  34966. * @param key the key to remove
  34967. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34968. */
  34969. remove(key: string): boolean;
  34970. /**
  34971. * Clear the whole content of the dictionary
  34972. */
  34973. clear(): void;
  34974. /**
  34975. * Gets the current count
  34976. */
  34977. get count(): number;
  34978. /**
  34979. * Execute a callback on each key/val of the dictionary.
  34980. * Note that you can remove any element in this dictionary in the callback implementation
  34981. * @param callback the callback to execute on a given key/value pair
  34982. */
  34983. forEach(callback: (key: string, val: T) => void): void;
  34984. /**
  34985. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34986. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34987. * Note that you can remove any element in this dictionary in the callback implementation
  34988. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34989. * @returns the first item
  34990. */
  34991. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34992. private _count;
  34993. private _data;
  34994. }
  34995. }
  34996. declare module BABYLON {
  34997. /** @hidden */
  34998. export interface ICollisionCoordinator {
  34999. createCollider(): Collider;
  35000. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35001. init(scene: Scene): void;
  35002. }
  35003. /** @hidden */
  35004. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35005. private _scene;
  35006. private _scaledPosition;
  35007. private _scaledVelocity;
  35008. private _finalPosition;
  35009. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35010. createCollider(): Collider;
  35011. init(scene: Scene): void;
  35012. private _collideWithWorld;
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /**
  35017. * Class used to manage all inputs for the scene.
  35018. */
  35019. export class InputManager {
  35020. /** The distance in pixel that you have to move to prevent some events */
  35021. static DragMovementThreshold: number;
  35022. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35023. static LongPressDelay: number;
  35024. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35025. static DoubleClickDelay: number;
  35026. /** If you need to check double click without raising a single click at first click, enable this flag */
  35027. static ExclusiveDoubleClickMode: boolean;
  35028. private _wheelEventName;
  35029. private _onPointerMove;
  35030. private _onPointerDown;
  35031. private _onPointerUp;
  35032. private _initClickEvent;
  35033. private _initActionManager;
  35034. private _delayedSimpleClick;
  35035. private _delayedSimpleClickTimeout;
  35036. private _previousDelayedSimpleClickTimeout;
  35037. private _meshPickProceed;
  35038. private _previousButtonPressed;
  35039. private _currentPickResult;
  35040. private _previousPickResult;
  35041. private _totalPointersPressed;
  35042. private _doubleClickOccured;
  35043. private _pointerOverMesh;
  35044. private _pickedDownMesh;
  35045. private _pickedUpMesh;
  35046. private _pointerX;
  35047. private _pointerY;
  35048. private _unTranslatedPointerX;
  35049. private _unTranslatedPointerY;
  35050. private _startingPointerPosition;
  35051. private _previousStartingPointerPosition;
  35052. private _startingPointerTime;
  35053. private _previousStartingPointerTime;
  35054. private _pointerCaptures;
  35055. private _onKeyDown;
  35056. private _onKeyUp;
  35057. private _onCanvasFocusObserver;
  35058. private _onCanvasBlurObserver;
  35059. private _scene;
  35060. /**
  35061. * Creates a new InputManager
  35062. * @param scene defines the hosting scene
  35063. */
  35064. constructor(scene: Scene);
  35065. /**
  35066. * Gets the mesh that is currently under the pointer
  35067. */
  35068. get meshUnderPointer(): Nullable<AbstractMesh>;
  35069. /**
  35070. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35071. */
  35072. get unTranslatedPointer(): Vector2;
  35073. /**
  35074. * Gets or sets the current on-screen X position of the pointer
  35075. */
  35076. get pointerX(): number;
  35077. set pointerX(value: number);
  35078. /**
  35079. * Gets or sets the current on-screen Y position of the pointer
  35080. */
  35081. get pointerY(): number;
  35082. set pointerY(value: number);
  35083. private _updatePointerPosition;
  35084. private _processPointerMove;
  35085. private _setRayOnPointerInfo;
  35086. private _checkPrePointerObservable;
  35087. /**
  35088. * Use this method to simulate a pointer move on a mesh
  35089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35092. */
  35093. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35094. /**
  35095. * Use this method to simulate a pointer down on a mesh
  35096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35099. */
  35100. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35101. private _processPointerDown;
  35102. /** @hidden */
  35103. _isPointerSwiping(): boolean;
  35104. /**
  35105. * Use this method to simulate a pointer up on a mesh
  35106. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35107. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35108. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35109. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35110. */
  35111. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35112. private _processPointerUp;
  35113. /**
  35114. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35115. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35116. * @returns true if the pointer was captured
  35117. */
  35118. isPointerCaptured(pointerId?: number): boolean;
  35119. /**
  35120. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35121. * @param attachUp defines if you want to attach events to pointerup
  35122. * @param attachDown defines if you want to attach events to pointerdown
  35123. * @param attachMove defines if you want to attach events to pointermove
  35124. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35125. */
  35126. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35127. /**
  35128. * Detaches all event handlers
  35129. */
  35130. detachControl(): void;
  35131. /**
  35132. * Force the value of meshUnderPointer
  35133. * @param mesh defines the mesh to use
  35134. */
  35135. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35136. /**
  35137. * Gets the mesh under the pointer
  35138. * @returns a Mesh or null if no mesh is under the pointer
  35139. */
  35140. getPointerOverMesh(): Nullable<AbstractMesh>;
  35141. }
  35142. }
  35143. declare module BABYLON {
  35144. /**
  35145. * Helper class used to generate session unique ID
  35146. */
  35147. export class UniqueIdGenerator {
  35148. private static _UniqueIdCounter;
  35149. /**
  35150. * Gets an unique (relatively to the current scene) Id
  35151. */
  35152. static get UniqueId(): number;
  35153. }
  35154. }
  35155. declare module BABYLON {
  35156. /**
  35157. * This class defines the direct association between an animation and a target
  35158. */
  35159. export class TargetedAnimation {
  35160. /**
  35161. * Animation to perform
  35162. */
  35163. animation: Animation;
  35164. /**
  35165. * Target to animate
  35166. */
  35167. target: any;
  35168. /**
  35169. * Serialize the object
  35170. * @returns the JSON object representing the current entity
  35171. */
  35172. serialize(): any;
  35173. }
  35174. /**
  35175. * Use this class to create coordinated animations on multiple targets
  35176. */
  35177. export class AnimationGroup implements IDisposable {
  35178. /** The name of the animation group */
  35179. name: string;
  35180. private _scene;
  35181. private _targetedAnimations;
  35182. private _animatables;
  35183. private _from;
  35184. private _to;
  35185. private _isStarted;
  35186. private _isPaused;
  35187. private _speedRatio;
  35188. private _loopAnimation;
  35189. private _isAdditive;
  35190. /**
  35191. * Gets or sets the unique id of the node
  35192. */
  35193. uniqueId: number;
  35194. /**
  35195. * This observable will notify when one animation have ended
  35196. */
  35197. onAnimationEndObservable: Observable<TargetedAnimation>;
  35198. /**
  35199. * Observer raised when one animation loops
  35200. */
  35201. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35202. /**
  35203. * Observer raised when all animations have looped
  35204. */
  35205. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35206. /**
  35207. * This observable will notify when all animations have ended.
  35208. */
  35209. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35210. /**
  35211. * This observable will notify when all animations have paused.
  35212. */
  35213. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35214. /**
  35215. * This observable will notify when all animations are playing.
  35216. */
  35217. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35218. /**
  35219. * Gets the first frame
  35220. */
  35221. get from(): number;
  35222. /**
  35223. * Gets the last frame
  35224. */
  35225. get to(): number;
  35226. /**
  35227. * Define if the animations are started
  35228. */
  35229. get isStarted(): boolean;
  35230. /**
  35231. * Gets a value indicating that the current group is playing
  35232. */
  35233. get isPlaying(): boolean;
  35234. /**
  35235. * Gets or sets the speed ratio to use for all animations
  35236. */
  35237. get speedRatio(): number;
  35238. /**
  35239. * Gets or sets the speed ratio to use for all animations
  35240. */
  35241. set speedRatio(value: number);
  35242. /**
  35243. * Gets or sets if all animations should loop or not
  35244. */
  35245. get loopAnimation(): boolean;
  35246. set loopAnimation(value: boolean);
  35247. /**
  35248. * Gets or sets if all animations should be evaluated additively
  35249. */
  35250. get isAdditive(): boolean;
  35251. set isAdditive(value: boolean);
  35252. /**
  35253. * Gets the targeted animations for this animation group
  35254. */
  35255. get targetedAnimations(): Array<TargetedAnimation>;
  35256. /**
  35257. * returning the list of animatables controlled by this animation group.
  35258. */
  35259. get animatables(): Array<Animatable>;
  35260. /**
  35261. * Instantiates a new Animation Group.
  35262. * This helps managing several animations at once.
  35263. * @see http://doc.babylonjs.com/how_to/group
  35264. * @param name Defines the name of the group
  35265. * @param scene Defines the scene the group belongs to
  35266. */
  35267. constructor(
  35268. /** The name of the animation group */
  35269. name: string, scene?: Nullable<Scene>);
  35270. /**
  35271. * Add an animation (with its target) in the group
  35272. * @param animation defines the animation we want to add
  35273. * @param target defines the target of the animation
  35274. * @returns the TargetedAnimation object
  35275. */
  35276. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35277. /**
  35278. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35279. * It can add constant keys at begin or end
  35280. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35281. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35282. * @returns the animation group
  35283. */
  35284. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35285. private _animationLoopCount;
  35286. private _animationLoopFlags;
  35287. private _processLoop;
  35288. /**
  35289. * Start all animations on given targets
  35290. * @param loop defines if animations must loop
  35291. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35292. * @param from defines the from key (optional)
  35293. * @param to defines the to key (optional)
  35294. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35295. * @returns the current animation group
  35296. */
  35297. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35298. /**
  35299. * Pause all animations
  35300. * @returns the animation group
  35301. */
  35302. pause(): AnimationGroup;
  35303. /**
  35304. * Play all animations to initial state
  35305. * This function will start() the animations if they were not started or will restart() them if they were paused
  35306. * @param loop defines if animations must loop
  35307. * @returns the animation group
  35308. */
  35309. play(loop?: boolean): AnimationGroup;
  35310. /**
  35311. * Reset all animations to initial state
  35312. * @returns the animation group
  35313. */
  35314. reset(): AnimationGroup;
  35315. /**
  35316. * Restart animations from key 0
  35317. * @returns the animation group
  35318. */
  35319. restart(): AnimationGroup;
  35320. /**
  35321. * Stop all animations
  35322. * @returns the animation group
  35323. */
  35324. stop(): AnimationGroup;
  35325. /**
  35326. * Set animation weight for all animatables
  35327. * @param weight defines the weight to use
  35328. * @return the animationGroup
  35329. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35330. */
  35331. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35332. /**
  35333. * Synchronize and normalize all animatables with a source animatable
  35334. * @param root defines the root animatable to synchronize with
  35335. * @return the animationGroup
  35336. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35337. */
  35338. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35339. /**
  35340. * Goes to a specific frame in this animation group
  35341. * @param frame the frame number to go to
  35342. * @return the animationGroup
  35343. */
  35344. goToFrame(frame: number): AnimationGroup;
  35345. /**
  35346. * Dispose all associated resources
  35347. */
  35348. dispose(): void;
  35349. private _checkAnimationGroupEnded;
  35350. /**
  35351. * Clone the current animation group and returns a copy
  35352. * @param newName defines the name of the new group
  35353. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35354. * @returns the new aniamtion group
  35355. */
  35356. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35357. /**
  35358. * Serializes the animationGroup to an object
  35359. * @returns Serialized object
  35360. */
  35361. serialize(): any;
  35362. /**
  35363. * Returns a new AnimationGroup object parsed from the source provided.
  35364. * @param parsedAnimationGroup defines the source
  35365. * @param scene defines the scene that will receive the animationGroup
  35366. * @returns a new AnimationGroup
  35367. */
  35368. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35369. /**
  35370. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35371. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35372. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35373. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35374. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35375. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35376. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35377. */
  35378. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35379. /**
  35380. * Returns the string "AnimationGroup"
  35381. * @returns "AnimationGroup"
  35382. */
  35383. getClassName(): string;
  35384. /**
  35385. * Creates a detailled string about the object
  35386. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35387. * @returns a string representing the object
  35388. */
  35389. toString(fullDetails?: boolean): string;
  35390. }
  35391. }
  35392. declare module BABYLON {
  35393. /**
  35394. * Define an interface for all classes that will hold resources
  35395. */
  35396. export interface IDisposable {
  35397. /**
  35398. * Releases all held resources
  35399. */
  35400. dispose(): void;
  35401. }
  35402. /** Interface defining initialization parameters for Scene class */
  35403. export interface SceneOptions {
  35404. /**
  35405. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35406. * It will improve performance when the number of geometries becomes important.
  35407. */
  35408. useGeometryUniqueIdsMap?: boolean;
  35409. /**
  35410. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35411. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35412. */
  35413. useMaterialMeshMap?: boolean;
  35414. /**
  35415. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35416. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35417. */
  35418. useClonedMeshMap?: boolean;
  35419. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35420. virtual?: boolean;
  35421. }
  35422. /**
  35423. * Represents a scene to be rendered by the engine.
  35424. * @see http://doc.babylonjs.com/features/scene
  35425. */
  35426. export class Scene extends AbstractScene implements IAnimatable {
  35427. /** The fog is deactivated */
  35428. static readonly FOGMODE_NONE: number;
  35429. /** The fog density is following an exponential function */
  35430. static readonly FOGMODE_EXP: number;
  35431. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35432. static readonly FOGMODE_EXP2: number;
  35433. /** The fog density is following a linear function. */
  35434. static readonly FOGMODE_LINEAR: number;
  35435. /**
  35436. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35437. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35438. */
  35439. static MinDeltaTime: number;
  35440. /**
  35441. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35442. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35443. */
  35444. static MaxDeltaTime: number;
  35445. /**
  35446. * Factory used to create the default material.
  35447. * @param name The name of the material to create
  35448. * @param scene The scene to create the material for
  35449. * @returns The default material
  35450. */
  35451. static DefaultMaterialFactory(scene: Scene): Material;
  35452. /**
  35453. * Factory used to create the a collision coordinator.
  35454. * @returns The collision coordinator
  35455. */
  35456. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35457. /** @hidden */
  35458. _inputManager: InputManager;
  35459. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35460. cameraToUseForPointers: Nullable<Camera>;
  35461. /** @hidden */
  35462. readonly _isScene: boolean;
  35463. /** @hidden */
  35464. _blockEntityCollection: boolean;
  35465. /**
  35466. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35467. */
  35468. autoClear: boolean;
  35469. /**
  35470. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35471. */
  35472. autoClearDepthAndStencil: boolean;
  35473. /**
  35474. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35475. */
  35476. clearColor: Color4;
  35477. /**
  35478. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35479. */
  35480. ambientColor: Color3;
  35481. /**
  35482. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35483. * It should only be one of the following (if not the default embedded one):
  35484. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35485. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35486. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35487. * The material properties need to be setup according to the type of texture in use.
  35488. */
  35489. environmentBRDFTexture: BaseTexture;
  35490. /** @hidden */
  35491. protected _environmentTexture: Nullable<BaseTexture>;
  35492. /**
  35493. * Texture used in all pbr material as the reflection texture.
  35494. * As in the majority of the scene they are the same (exception for multi room and so on),
  35495. * this is easier to reference from here than from all the materials.
  35496. */
  35497. get environmentTexture(): Nullable<BaseTexture>;
  35498. /**
  35499. * Texture used in all pbr material as the reflection texture.
  35500. * As in the majority of the scene they are the same (exception for multi room and so on),
  35501. * this is easier to set here than in all the materials.
  35502. */
  35503. set environmentTexture(value: Nullable<BaseTexture>);
  35504. /** @hidden */
  35505. protected _environmentIntensity: number;
  35506. /**
  35507. * Intensity of the environment in all pbr material.
  35508. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35509. * As in the majority of the scene they are the same (exception for multi room and so on),
  35510. * this is easier to reference from here than from all the materials.
  35511. */
  35512. get environmentIntensity(): number;
  35513. /**
  35514. * Intensity of the environment in all pbr material.
  35515. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35516. * As in the majority of the scene they are the same (exception for multi room and so on),
  35517. * this is easier to set here than in all the materials.
  35518. */
  35519. set environmentIntensity(value: number);
  35520. /** @hidden */
  35521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35522. /**
  35523. * Default image processing configuration used either in the rendering
  35524. * Forward main pass or through the imageProcessingPostProcess if present.
  35525. * As in the majority of the scene they are the same (exception for multi camera),
  35526. * this is easier to reference from here than from all the materials and post process.
  35527. *
  35528. * No setter as we it is a shared configuration, you can set the values instead.
  35529. */
  35530. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35531. private _forceWireframe;
  35532. /**
  35533. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35534. */
  35535. set forceWireframe(value: boolean);
  35536. get forceWireframe(): boolean;
  35537. private _skipFrustumClipping;
  35538. /**
  35539. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35540. */
  35541. set skipFrustumClipping(value: boolean);
  35542. get skipFrustumClipping(): boolean;
  35543. private _forcePointsCloud;
  35544. /**
  35545. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35546. */
  35547. set forcePointsCloud(value: boolean);
  35548. get forcePointsCloud(): boolean;
  35549. /**
  35550. * Gets or sets the active clipplane 1
  35551. */
  35552. clipPlane: Nullable<Plane>;
  35553. /**
  35554. * Gets or sets the active clipplane 2
  35555. */
  35556. clipPlane2: Nullable<Plane>;
  35557. /**
  35558. * Gets or sets the active clipplane 3
  35559. */
  35560. clipPlane3: Nullable<Plane>;
  35561. /**
  35562. * Gets or sets the active clipplane 4
  35563. */
  35564. clipPlane4: Nullable<Plane>;
  35565. /**
  35566. * Gets or sets the active clipplane 5
  35567. */
  35568. clipPlane5: Nullable<Plane>;
  35569. /**
  35570. * Gets or sets the active clipplane 6
  35571. */
  35572. clipPlane6: Nullable<Plane>;
  35573. /**
  35574. * Gets or sets a boolean indicating if animations are enabled
  35575. */
  35576. animationsEnabled: boolean;
  35577. private _animationPropertiesOverride;
  35578. /**
  35579. * Gets or sets the animation properties override
  35580. */
  35581. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35582. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35583. /**
  35584. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35585. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35586. */
  35587. useConstantAnimationDeltaTime: boolean;
  35588. /**
  35589. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35590. * Please note that it requires to run a ray cast through the scene on every frame
  35591. */
  35592. constantlyUpdateMeshUnderPointer: boolean;
  35593. /**
  35594. * Defines the HTML cursor to use when hovering over interactive elements
  35595. */
  35596. hoverCursor: string;
  35597. /**
  35598. * Defines the HTML default cursor to use (empty by default)
  35599. */
  35600. defaultCursor: string;
  35601. /**
  35602. * Defines whether cursors are handled by the scene.
  35603. */
  35604. doNotHandleCursors: boolean;
  35605. /**
  35606. * This is used to call preventDefault() on pointer down
  35607. * in order to block unwanted artifacts like system double clicks
  35608. */
  35609. preventDefaultOnPointerDown: boolean;
  35610. /**
  35611. * This is used to call preventDefault() on pointer up
  35612. * in order to block unwanted artifacts like system double clicks
  35613. */
  35614. preventDefaultOnPointerUp: boolean;
  35615. /**
  35616. * Gets or sets user defined metadata
  35617. */
  35618. metadata: any;
  35619. /**
  35620. * For internal use only. Please do not use.
  35621. */
  35622. reservedDataStore: any;
  35623. /**
  35624. * Gets the name of the plugin used to load this scene (null by default)
  35625. */
  35626. loadingPluginName: string;
  35627. /**
  35628. * Use this array to add regular expressions used to disable offline support for specific urls
  35629. */
  35630. disableOfflineSupportExceptionRules: RegExp[];
  35631. /**
  35632. * An event triggered when the scene is disposed.
  35633. */
  35634. onDisposeObservable: Observable<Scene>;
  35635. private _onDisposeObserver;
  35636. /** Sets a function to be executed when this scene is disposed. */
  35637. set onDispose(callback: () => void);
  35638. /**
  35639. * An event triggered before rendering the scene (right after animations and physics)
  35640. */
  35641. onBeforeRenderObservable: Observable<Scene>;
  35642. private _onBeforeRenderObserver;
  35643. /** Sets a function to be executed before rendering this scene */
  35644. set beforeRender(callback: Nullable<() => void>);
  35645. /**
  35646. * An event triggered after rendering the scene
  35647. */
  35648. onAfterRenderObservable: Observable<Scene>;
  35649. /**
  35650. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35651. */
  35652. onAfterRenderCameraObservable: Observable<Camera>;
  35653. private _onAfterRenderObserver;
  35654. /** Sets a function to be executed after rendering this scene */
  35655. set afterRender(callback: Nullable<() => void>);
  35656. /**
  35657. * An event triggered before animating the scene
  35658. */
  35659. onBeforeAnimationsObservable: Observable<Scene>;
  35660. /**
  35661. * An event triggered after animations processing
  35662. */
  35663. onAfterAnimationsObservable: Observable<Scene>;
  35664. /**
  35665. * An event triggered before draw calls are ready to be sent
  35666. */
  35667. onBeforeDrawPhaseObservable: Observable<Scene>;
  35668. /**
  35669. * An event triggered after draw calls have been sent
  35670. */
  35671. onAfterDrawPhaseObservable: Observable<Scene>;
  35672. /**
  35673. * An event triggered when the scene is ready
  35674. */
  35675. onReadyObservable: Observable<Scene>;
  35676. /**
  35677. * An event triggered before rendering a camera
  35678. */
  35679. onBeforeCameraRenderObservable: Observable<Camera>;
  35680. private _onBeforeCameraRenderObserver;
  35681. /** Sets a function to be executed before rendering a camera*/
  35682. set beforeCameraRender(callback: () => void);
  35683. /**
  35684. * An event triggered after rendering a camera
  35685. */
  35686. onAfterCameraRenderObservable: Observable<Camera>;
  35687. private _onAfterCameraRenderObserver;
  35688. /** Sets a function to be executed after rendering a camera*/
  35689. set afterCameraRender(callback: () => void);
  35690. /**
  35691. * An event triggered when active meshes evaluation is about to start
  35692. */
  35693. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35694. /**
  35695. * An event triggered when active meshes evaluation is done
  35696. */
  35697. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35698. /**
  35699. * An event triggered when particles rendering is about to start
  35700. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35701. */
  35702. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35703. /**
  35704. * An event triggered when particles rendering is done
  35705. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35706. */
  35707. onAfterParticlesRenderingObservable: Observable<Scene>;
  35708. /**
  35709. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35710. */
  35711. onDataLoadedObservable: Observable<Scene>;
  35712. /**
  35713. * An event triggered when a camera is created
  35714. */
  35715. onNewCameraAddedObservable: Observable<Camera>;
  35716. /**
  35717. * An event triggered when a camera is removed
  35718. */
  35719. onCameraRemovedObservable: Observable<Camera>;
  35720. /**
  35721. * An event triggered when a light is created
  35722. */
  35723. onNewLightAddedObservable: Observable<Light>;
  35724. /**
  35725. * An event triggered when a light is removed
  35726. */
  35727. onLightRemovedObservable: Observable<Light>;
  35728. /**
  35729. * An event triggered when a geometry is created
  35730. */
  35731. onNewGeometryAddedObservable: Observable<Geometry>;
  35732. /**
  35733. * An event triggered when a geometry is removed
  35734. */
  35735. onGeometryRemovedObservable: Observable<Geometry>;
  35736. /**
  35737. * An event triggered when a transform node is created
  35738. */
  35739. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35740. /**
  35741. * An event triggered when a transform node is removed
  35742. */
  35743. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35744. /**
  35745. * An event triggered when a mesh is created
  35746. */
  35747. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35748. /**
  35749. * An event triggered when a mesh is removed
  35750. */
  35751. onMeshRemovedObservable: Observable<AbstractMesh>;
  35752. /**
  35753. * An event triggered when a skeleton is created
  35754. */
  35755. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35756. /**
  35757. * An event triggered when a skeleton is removed
  35758. */
  35759. onSkeletonRemovedObservable: Observable<Skeleton>;
  35760. /**
  35761. * An event triggered when a material is created
  35762. */
  35763. onNewMaterialAddedObservable: Observable<Material>;
  35764. /**
  35765. * An event triggered when a material is removed
  35766. */
  35767. onMaterialRemovedObservable: Observable<Material>;
  35768. /**
  35769. * An event triggered when a texture is created
  35770. */
  35771. onNewTextureAddedObservable: Observable<BaseTexture>;
  35772. /**
  35773. * An event triggered when a texture is removed
  35774. */
  35775. onTextureRemovedObservable: Observable<BaseTexture>;
  35776. /**
  35777. * An event triggered when render targets are about to be rendered
  35778. * Can happen multiple times per frame.
  35779. */
  35780. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35781. /**
  35782. * An event triggered when render targets were rendered.
  35783. * Can happen multiple times per frame.
  35784. */
  35785. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35786. /**
  35787. * An event triggered before calculating deterministic simulation step
  35788. */
  35789. onBeforeStepObservable: Observable<Scene>;
  35790. /**
  35791. * An event triggered after calculating deterministic simulation step
  35792. */
  35793. onAfterStepObservable: Observable<Scene>;
  35794. /**
  35795. * An event triggered when the activeCamera property is updated
  35796. */
  35797. onActiveCameraChanged: Observable<Scene>;
  35798. /**
  35799. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35800. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35801. * 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)
  35802. */
  35803. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35804. /**
  35805. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35806. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35807. * 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)
  35808. */
  35809. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35810. /**
  35811. * This Observable will when a mesh has been imported into the scene.
  35812. */
  35813. onMeshImportedObservable: Observable<AbstractMesh>;
  35814. /**
  35815. * This Observable will when an animation file has been imported into the scene.
  35816. */
  35817. onAnimationFileImportedObservable: Observable<Scene>;
  35818. /**
  35819. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35820. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35821. */
  35822. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35823. /** @hidden */
  35824. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35825. /**
  35826. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35827. */
  35828. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35829. /**
  35830. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35831. */
  35832. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35833. /**
  35834. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35835. */
  35836. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35837. /** Callback called when a pointer move is detected */
  35838. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35839. /** Callback called when a pointer down is detected */
  35840. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35841. /** Callback called when a pointer up is detected */
  35842. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35843. /** Callback called when a pointer pick is detected */
  35844. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35845. /**
  35846. * 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).
  35847. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35848. */
  35849. onPrePointerObservable: Observable<PointerInfoPre>;
  35850. /**
  35851. * Observable event triggered each time an input event is received from the rendering canvas
  35852. */
  35853. onPointerObservable: Observable<PointerInfo>;
  35854. /**
  35855. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35856. */
  35857. get unTranslatedPointer(): Vector2;
  35858. /**
  35859. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35860. */
  35861. static get DragMovementThreshold(): number;
  35862. static set DragMovementThreshold(value: number);
  35863. /**
  35864. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35865. */
  35866. static get LongPressDelay(): number;
  35867. static set LongPressDelay(value: number);
  35868. /**
  35869. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35870. */
  35871. static get DoubleClickDelay(): number;
  35872. static set DoubleClickDelay(value: number);
  35873. /** If you need to check double click without raising a single click at first click, enable this flag */
  35874. static get ExclusiveDoubleClickMode(): boolean;
  35875. static set ExclusiveDoubleClickMode(value: boolean);
  35876. /** @hidden */
  35877. _mirroredCameraPosition: Nullable<Vector3>;
  35878. /**
  35879. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35880. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35881. */
  35882. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35883. /**
  35884. * Observable event triggered each time an keyboard event is received from the hosting window
  35885. */
  35886. onKeyboardObservable: Observable<KeyboardInfo>;
  35887. private _useRightHandedSystem;
  35888. /**
  35889. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35890. */
  35891. set useRightHandedSystem(value: boolean);
  35892. get useRightHandedSystem(): boolean;
  35893. private _timeAccumulator;
  35894. private _currentStepId;
  35895. private _currentInternalStep;
  35896. /**
  35897. * Sets the step Id used by deterministic lock step
  35898. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35899. * @param newStepId defines the step Id
  35900. */
  35901. setStepId(newStepId: number): void;
  35902. /**
  35903. * Gets the step Id used by deterministic lock step
  35904. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35905. * @returns the step Id
  35906. */
  35907. getStepId(): number;
  35908. /**
  35909. * Gets the internal step used by deterministic lock step
  35910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35911. * @returns the internal step
  35912. */
  35913. getInternalStep(): number;
  35914. private _fogEnabled;
  35915. /**
  35916. * Gets or sets a boolean indicating if fog is enabled on this scene
  35917. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35918. * (Default is true)
  35919. */
  35920. set fogEnabled(value: boolean);
  35921. get fogEnabled(): boolean;
  35922. private _fogMode;
  35923. /**
  35924. * Gets or sets the fog mode to use
  35925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35926. * | mode | value |
  35927. * | --- | --- |
  35928. * | FOGMODE_NONE | 0 |
  35929. * | FOGMODE_EXP | 1 |
  35930. * | FOGMODE_EXP2 | 2 |
  35931. * | FOGMODE_LINEAR | 3 |
  35932. */
  35933. set fogMode(value: number);
  35934. get fogMode(): number;
  35935. /**
  35936. * Gets or sets the fog color to use
  35937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35938. * (Default is Color3(0.2, 0.2, 0.3))
  35939. */
  35940. fogColor: Color3;
  35941. /**
  35942. * Gets or sets the fog density to use
  35943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35944. * (Default is 0.1)
  35945. */
  35946. fogDensity: number;
  35947. /**
  35948. * Gets or sets the fog start distance to use
  35949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35950. * (Default is 0)
  35951. */
  35952. fogStart: number;
  35953. /**
  35954. * Gets or sets the fog end distance to use
  35955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35956. * (Default is 1000)
  35957. */
  35958. fogEnd: number;
  35959. private _shadowsEnabled;
  35960. /**
  35961. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35962. */
  35963. set shadowsEnabled(value: boolean);
  35964. get shadowsEnabled(): boolean;
  35965. private _lightsEnabled;
  35966. /**
  35967. * Gets or sets a boolean indicating if lights are enabled on this scene
  35968. */
  35969. set lightsEnabled(value: boolean);
  35970. get lightsEnabled(): boolean;
  35971. /** All of the active cameras added to this scene. */
  35972. activeCameras: Camera[];
  35973. /** @hidden */
  35974. _activeCamera: Nullable<Camera>;
  35975. /** Gets or sets the current active camera */
  35976. get activeCamera(): Nullable<Camera>;
  35977. set activeCamera(value: Nullable<Camera>);
  35978. private _defaultMaterial;
  35979. /** The default material used on meshes when no material is affected */
  35980. get defaultMaterial(): Material;
  35981. /** The default material used on meshes when no material is affected */
  35982. set defaultMaterial(value: Material);
  35983. private _texturesEnabled;
  35984. /**
  35985. * Gets or sets a boolean indicating if textures are enabled on this scene
  35986. */
  35987. set texturesEnabled(value: boolean);
  35988. get texturesEnabled(): boolean;
  35989. /**
  35990. * Gets or sets a boolean indicating if particles are enabled on this scene
  35991. */
  35992. particlesEnabled: boolean;
  35993. /**
  35994. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35995. */
  35996. spritesEnabled: boolean;
  35997. private _skeletonsEnabled;
  35998. /**
  35999. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36000. */
  36001. set skeletonsEnabled(value: boolean);
  36002. get skeletonsEnabled(): boolean;
  36003. /**
  36004. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36005. */
  36006. lensFlaresEnabled: boolean;
  36007. /**
  36008. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36009. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36010. */
  36011. collisionsEnabled: boolean;
  36012. private _collisionCoordinator;
  36013. /** @hidden */
  36014. get collisionCoordinator(): ICollisionCoordinator;
  36015. /**
  36016. * Defines the gravity applied to this scene (used only for collisions)
  36017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36018. */
  36019. gravity: Vector3;
  36020. /**
  36021. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36022. */
  36023. postProcessesEnabled: boolean;
  36024. /**
  36025. * The list of postprocesses added to the scene
  36026. */
  36027. postProcesses: PostProcess[];
  36028. /**
  36029. * Gets the current postprocess manager
  36030. */
  36031. postProcessManager: PostProcessManager;
  36032. /**
  36033. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36034. */
  36035. renderTargetsEnabled: boolean;
  36036. /**
  36037. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36038. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36039. */
  36040. dumpNextRenderTargets: boolean;
  36041. /**
  36042. * The list of user defined render targets added to the scene
  36043. */
  36044. customRenderTargets: RenderTargetTexture[];
  36045. /**
  36046. * Defines if texture loading must be delayed
  36047. * If true, textures will only be loaded when they need to be rendered
  36048. */
  36049. useDelayedTextureLoading: boolean;
  36050. /**
  36051. * Gets the list of meshes imported to the scene through SceneLoader
  36052. */
  36053. importedMeshesFiles: String[];
  36054. /**
  36055. * Gets or sets a boolean indicating if probes are enabled on this scene
  36056. */
  36057. probesEnabled: boolean;
  36058. /**
  36059. * Gets or sets the current offline provider to use to store scene data
  36060. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36061. */
  36062. offlineProvider: IOfflineProvider;
  36063. /**
  36064. * Gets or sets the action manager associated with the scene
  36065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36066. */
  36067. actionManager: AbstractActionManager;
  36068. private _meshesForIntersections;
  36069. /**
  36070. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36071. */
  36072. proceduralTexturesEnabled: boolean;
  36073. private _engine;
  36074. private _totalVertices;
  36075. /** @hidden */
  36076. _activeIndices: PerfCounter;
  36077. /** @hidden */
  36078. _activeParticles: PerfCounter;
  36079. /** @hidden */
  36080. _activeBones: PerfCounter;
  36081. private _animationRatio;
  36082. /** @hidden */
  36083. _animationTimeLast: number;
  36084. /** @hidden */
  36085. _animationTime: number;
  36086. /**
  36087. * Gets or sets a general scale for animation speed
  36088. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36089. */
  36090. animationTimeScale: number;
  36091. /** @hidden */
  36092. _cachedMaterial: Nullable<Material>;
  36093. /** @hidden */
  36094. _cachedEffect: Nullable<Effect>;
  36095. /** @hidden */
  36096. _cachedVisibility: Nullable<number>;
  36097. private _renderId;
  36098. private _frameId;
  36099. private _executeWhenReadyTimeoutId;
  36100. private _intermediateRendering;
  36101. private _viewUpdateFlag;
  36102. private _projectionUpdateFlag;
  36103. /** @hidden */
  36104. _toBeDisposed: Nullable<IDisposable>[];
  36105. private _activeRequests;
  36106. /** @hidden */
  36107. _pendingData: any[];
  36108. private _isDisposed;
  36109. /**
  36110. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36111. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36112. */
  36113. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36114. private _activeMeshes;
  36115. private _processedMaterials;
  36116. private _renderTargets;
  36117. /** @hidden */
  36118. _activeParticleSystems: SmartArray<IParticleSystem>;
  36119. private _activeSkeletons;
  36120. private _softwareSkinnedMeshes;
  36121. private _renderingManager;
  36122. /** @hidden */
  36123. _activeAnimatables: Animatable[];
  36124. private _transformMatrix;
  36125. private _sceneUbo;
  36126. /** @hidden */
  36127. _viewMatrix: Matrix;
  36128. private _projectionMatrix;
  36129. /** @hidden */
  36130. _forcedViewPosition: Nullable<Vector3>;
  36131. /** @hidden */
  36132. _frustumPlanes: Plane[];
  36133. /**
  36134. * Gets the list of frustum planes (built from the active camera)
  36135. */
  36136. get frustumPlanes(): Plane[];
  36137. /**
  36138. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36139. * This is useful if there are more lights that the maximum simulteanous authorized
  36140. */
  36141. requireLightSorting: boolean;
  36142. /** @hidden */
  36143. readonly useMaterialMeshMap: boolean;
  36144. /** @hidden */
  36145. readonly useClonedMeshMap: boolean;
  36146. private _externalData;
  36147. private _uid;
  36148. /**
  36149. * @hidden
  36150. * Backing store of defined scene components.
  36151. */
  36152. _components: ISceneComponent[];
  36153. /**
  36154. * @hidden
  36155. * Backing store of defined scene components.
  36156. */
  36157. _serializableComponents: ISceneSerializableComponent[];
  36158. /**
  36159. * List of components to register on the next registration step.
  36160. */
  36161. private _transientComponents;
  36162. /**
  36163. * Registers the transient components if needed.
  36164. */
  36165. private _registerTransientComponents;
  36166. /**
  36167. * @hidden
  36168. * Add a component to the scene.
  36169. * Note that the ccomponent could be registered on th next frame if this is called after
  36170. * the register component stage.
  36171. * @param component Defines the component to add to the scene
  36172. */
  36173. _addComponent(component: ISceneComponent): void;
  36174. /**
  36175. * @hidden
  36176. * Gets a component from the scene.
  36177. * @param name defines the name of the component to retrieve
  36178. * @returns the component or null if not present
  36179. */
  36180. _getComponent(name: string): Nullable<ISceneComponent>;
  36181. /**
  36182. * @hidden
  36183. * Defines the actions happening before camera updates.
  36184. */
  36185. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36186. /**
  36187. * @hidden
  36188. * Defines the actions happening before clear the canvas.
  36189. */
  36190. _beforeClearStage: Stage<SimpleStageAction>;
  36191. /**
  36192. * @hidden
  36193. * Defines the actions when collecting render targets for the frame.
  36194. */
  36195. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36196. /**
  36197. * @hidden
  36198. * Defines the actions happening for one camera in the frame.
  36199. */
  36200. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36201. /**
  36202. * @hidden
  36203. * Defines the actions happening during the per mesh ready checks.
  36204. */
  36205. _isReadyForMeshStage: Stage<MeshStageAction>;
  36206. /**
  36207. * @hidden
  36208. * Defines the actions happening before evaluate active mesh checks.
  36209. */
  36210. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36211. /**
  36212. * @hidden
  36213. * Defines the actions happening during the evaluate sub mesh checks.
  36214. */
  36215. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36216. /**
  36217. * @hidden
  36218. * Defines the actions happening during the active mesh stage.
  36219. */
  36220. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36221. /**
  36222. * @hidden
  36223. * Defines the actions happening during the per camera render target step.
  36224. */
  36225. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36226. /**
  36227. * @hidden
  36228. * Defines the actions happening just before the active camera is drawing.
  36229. */
  36230. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36231. /**
  36232. * @hidden
  36233. * Defines the actions happening just before a render target is drawing.
  36234. */
  36235. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36236. /**
  36237. * @hidden
  36238. * Defines the actions happening just before a rendering group is drawing.
  36239. */
  36240. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36241. /**
  36242. * @hidden
  36243. * Defines the actions happening just before a mesh is drawing.
  36244. */
  36245. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36246. /**
  36247. * @hidden
  36248. * Defines the actions happening just after a mesh has been drawn.
  36249. */
  36250. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36251. /**
  36252. * @hidden
  36253. * Defines the actions happening just after a rendering group has been drawn.
  36254. */
  36255. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36256. /**
  36257. * @hidden
  36258. * Defines the actions happening just after the active camera has been drawn.
  36259. */
  36260. _afterCameraDrawStage: Stage<CameraStageAction>;
  36261. /**
  36262. * @hidden
  36263. * Defines the actions happening just after a render target has been drawn.
  36264. */
  36265. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36266. /**
  36267. * @hidden
  36268. * Defines the actions happening just after rendering all cameras and computing intersections.
  36269. */
  36270. _afterRenderStage: Stage<SimpleStageAction>;
  36271. /**
  36272. * @hidden
  36273. * Defines the actions happening when a pointer move event happens.
  36274. */
  36275. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36276. /**
  36277. * @hidden
  36278. * Defines the actions happening when a pointer down event happens.
  36279. */
  36280. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36281. /**
  36282. * @hidden
  36283. * Defines the actions happening when a pointer up event happens.
  36284. */
  36285. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36286. /**
  36287. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36288. */
  36289. private geometriesByUniqueId;
  36290. /**
  36291. * Creates a new Scene
  36292. * @param engine defines the engine to use to render this scene
  36293. * @param options defines the scene options
  36294. */
  36295. constructor(engine: Engine, options?: SceneOptions);
  36296. /**
  36297. * Gets a string idenfifying the name of the class
  36298. * @returns "Scene" string
  36299. */
  36300. getClassName(): string;
  36301. private _defaultMeshCandidates;
  36302. /**
  36303. * @hidden
  36304. */
  36305. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36306. private _defaultSubMeshCandidates;
  36307. /**
  36308. * @hidden
  36309. */
  36310. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36311. /**
  36312. * Sets the default candidate providers for the scene.
  36313. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36314. * and getCollidingSubMeshCandidates to their default function
  36315. */
  36316. setDefaultCandidateProviders(): void;
  36317. /**
  36318. * Gets the mesh that is currently under the pointer
  36319. */
  36320. get meshUnderPointer(): Nullable<AbstractMesh>;
  36321. /**
  36322. * Gets or sets the current on-screen X position of the pointer
  36323. */
  36324. get pointerX(): number;
  36325. set pointerX(value: number);
  36326. /**
  36327. * Gets or sets the current on-screen Y position of the pointer
  36328. */
  36329. get pointerY(): number;
  36330. set pointerY(value: number);
  36331. /**
  36332. * Gets the cached material (ie. the latest rendered one)
  36333. * @returns the cached material
  36334. */
  36335. getCachedMaterial(): Nullable<Material>;
  36336. /**
  36337. * Gets the cached effect (ie. the latest rendered one)
  36338. * @returns the cached effect
  36339. */
  36340. getCachedEffect(): Nullable<Effect>;
  36341. /**
  36342. * Gets the cached visibility state (ie. the latest rendered one)
  36343. * @returns the cached visibility state
  36344. */
  36345. getCachedVisibility(): Nullable<number>;
  36346. /**
  36347. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36348. * @param material defines the current material
  36349. * @param effect defines the current effect
  36350. * @param visibility defines the current visibility state
  36351. * @returns true if one parameter is not cached
  36352. */
  36353. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36354. /**
  36355. * Gets the engine associated with the scene
  36356. * @returns an Engine
  36357. */
  36358. getEngine(): Engine;
  36359. /**
  36360. * Gets the total number of vertices rendered per frame
  36361. * @returns the total number of vertices rendered per frame
  36362. */
  36363. getTotalVertices(): number;
  36364. /**
  36365. * Gets the performance counter for total vertices
  36366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36367. */
  36368. get totalVerticesPerfCounter(): PerfCounter;
  36369. /**
  36370. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36371. * @returns the total number of active indices rendered per frame
  36372. */
  36373. getActiveIndices(): number;
  36374. /**
  36375. * Gets the performance counter for active indices
  36376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36377. */
  36378. get totalActiveIndicesPerfCounter(): PerfCounter;
  36379. /**
  36380. * Gets the total number of active particles rendered per frame
  36381. * @returns the total number of active particles rendered per frame
  36382. */
  36383. getActiveParticles(): number;
  36384. /**
  36385. * Gets the performance counter for active particles
  36386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36387. */
  36388. get activeParticlesPerfCounter(): PerfCounter;
  36389. /**
  36390. * Gets the total number of active bones rendered per frame
  36391. * @returns the total number of active bones rendered per frame
  36392. */
  36393. getActiveBones(): number;
  36394. /**
  36395. * Gets the performance counter for active bones
  36396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36397. */
  36398. get activeBonesPerfCounter(): PerfCounter;
  36399. /**
  36400. * Gets the array of active meshes
  36401. * @returns an array of AbstractMesh
  36402. */
  36403. getActiveMeshes(): SmartArray<AbstractMesh>;
  36404. /**
  36405. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36406. * @returns a number
  36407. */
  36408. getAnimationRatio(): number;
  36409. /**
  36410. * Gets an unique Id for the current render phase
  36411. * @returns a number
  36412. */
  36413. getRenderId(): number;
  36414. /**
  36415. * Gets an unique Id for the current frame
  36416. * @returns a number
  36417. */
  36418. getFrameId(): number;
  36419. /** Call this function if you want to manually increment the render Id*/
  36420. incrementRenderId(): void;
  36421. private _createUbo;
  36422. /**
  36423. * Use this method to simulate a pointer move on a mesh
  36424. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36425. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36426. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36427. * @returns the current scene
  36428. */
  36429. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36430. /**
  36431. * Use this method to simulate a pointer down on a mesh
  36432. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36433. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36434. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36435. * @returns the current scene
  36436. */
  36437. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36438. /**
  36439. * Use this method to simulate a pointer up on a mesh
  36440. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36441. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36442. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36443. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36444. * @returns the current scene
  36445. */
  36446. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36447. /**
  36448. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36449. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36450. * @returns true if the pointer was captured
  36451. */
  36452. isPointerCaptured(pointerId?: number): boolean;
  36453. /**
  36454. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36455. * @param attachUp defines if you want to attach events to pointerup
  36456. * @param attachDown defines if you want to attach events to pointerdown
  36457. * @param attachMove defines if you want to attach events to pointermove
  36458. */
  36459. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36460. /** Detaches all event handlers*/
  36461. detachControl(): void;
  36462. /**
  36463. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36464. * Delay loaded resources are not taking in account
  36465. * @return true if all required resources are ready
  36466. */
  36467. isReady(): boolean;
  36468. /** Resets all cached information relative to material (including effect and visibility) */
  36469. resetCachedMaterial(): void;
  36470. /**
  36471. * Registers a function to be called before every frame render
  36472. * @param func defines the function to register
  36473. */
  36474. registerBeforeRender(func: () => void): void;
  36475. /**
  36476. * Unregisters a function called before every frame render
  36477. * @param func defines the function to unregister
  36478. */
  36479. unregisterBeforeRender(func: () => void): void;
  36480. /**
  36481. * Registers a function to be called after every frame render
  36482. * @param func defines the function to register
  36483. */
  36484. registerAfterRender(func: () => void): void;
  36485. /**
  36486. * Unregisters a function called after every frame render
  36487. * @param func defines the function to unregister
  36488. */
  36489. unregisterAfterRender(func: () => void): void;
  36490. private _executeOnceBeforeRender;
  36491. /**
  36492. * The provided function will run before render once and will be disposed afterwards.
  36493. * A timeout delay can be provided so that the function will be executed in N ms.
  36494. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36495. * @param func The function to be executed.
  36496. * @param timeout optional delay in ms
  36497. */
  36498. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36499. /** @hidden */
  36500. _addPendingData(data: any): void;
  36501. /** @hidden */
  36502. _removePendingData(data: any): void;
  36503. /**
  36504. * Returns the number of items waiting to be loaded
  36505. * @returns the number of items waiting to be loaded
  36506. */
  36507. getWaitingItemsCount(): number;
  36508. /**
  36509. * Returns a boolean indicating if the scene is still loading data
  36510. */
  36511. get isLoading(): boolean;
  36512. /**
  36513. * Registers a function to be executed when the scene is ready
  36514. * @param {Function} func - the function to be executed
  36515. */
  36516. executeWhenReady(func: () => void): void;
  36517. /**
  36518. * Returns a promise that resolves when the scene is ready
  36519. * @returns A promise that resolves when the scene is ready
  36520. */
  36521. whenReadyAsync(): Promise<void>;
  36522. /** @hidden */
  36523. _checkIsReady(): void;
  36524. /**
  36525. * Gets all animatable attached to the scene
  36526. */
  36527. get animatables(): Animatable[];
  36528. /**
  36529. * Resets the last animation time frame.
  36530. * Useful to override when animations start running when loading a scene for the first time.
  36531. */
  36532. resetLastAnimationTimeFrame(): void;
  36533. /**
  36534. * Gets the current view matrix
  36535. * @returns a Matrix
  36536. */
  36537. getViewMatrix(): Matrix;
  36538. /**
  36539. * Gets the current projection matrix
  36540. * @returns a Matrix
  36541. */
  36542. getProjectionMatrix(): Matrix;
  36543. /**
  36544. * Gets the current transform matrix
  36545. * @returns a Matrix made of View * Projection
  36546. */
  36547. getTransformMatrix(): Matrix;
  36548. /**
  36549. * Sets the current transform matrix
  36550. * @param viewL defines the View matrix to use
  36551. * @param projectionL defines the Projection matrix to use
  36552. * @param viewR defines the right View matrix to use (if provided)
  36553. * @param projectionR defines the right Projection matrix to use (if provided)
  36554. */
  36555. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36556. /**
  36557. * Gets the uniform buffer used to store scene data
  36558. * @returns a UniformBuffer
  36559. */
  36560. getSceneUniformBuffer(): UniformBuffer;
  36561. /**
  36562. * Gets an unique (relatively to the current scene) Id
  36563. * @returns an unique number for the scene
  36564. */
  36565. getUniqueId(): number;
  36566. /**
  36567. * Add a mesh to the list of scene's meshes
  36568. * @param newMesh defines the mesh to add
  36569. * @param recursive if all child meshes should also be added to the scene
  36570. */
  36571. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36572. /**
  36573. * Remove a mesh for the list of scene's meshes
  36574. * @param toRemove defines the mesh to remove
  36575. * @param recursive if all child meshes should also be removed from the scene
  36576. * @returns the index where the mesh was in the mesh list
  36577. */
  36578. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36579. /**
  36580. * Add a transform node to the list of scene's transform nodes
  36581. * @param newTransformNode defines the transform node to add
  36582. */
  36583. addTransformNode(newTransformNode: TransformNode): void;
  36584. /**
  36585. * Remove a transform node for the list of scene's transform nodes
  36586. * @param toRemove defines the transform node to remove
  36587. * @returns the index where the transform node was in the transform node list
  36588. */
  36589. removeTransformNode(toRemove: TransformNode): number;
  36590. /**
  36591. * Remove a skeleton for the list of scene's skeletons
  36592. * @param toRemove defines the skeleton to remove
  36593. * @returns the index where the skeleton was in the skeleton list
  36594. */
  36595. removeSkeleton(toRemove: Skeleton): number;
  36596. /**
  36597. * Remove a morph target for the list of scene's morph targets
  36598. * @param toRemove defines the morph target to remove
  36599. * @returns the index where the morph target was in the morph target list
  36600. */
  36601. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36602. /**
  36603. * Remove a light for the list of scene's lights
  36604. * @param toRemove defines the light to remove
  36605. * @returns the index where the light was in the light list
  36606. */
  36607. removeLight(toRemove: Light): number;
  36608. /**
  36609. * Remove a camera for the list of scene's cameras
  36610. * @param toRemove defines the camera to remove
  36611. * @returns the index where the camera was in the camera list
  36612. */
  36613. removeCamera(toRemove: Camera): number;
  36614. /**
  36615. * Remove a particle system for the list of scene's particle systems
  36616. * @param toRemove defines the particle system to remove
  36617. * @returns the index where the particle system was in the particle system list
  36618. */
  36619. removeParticleSystem(toRemove: IParticleSystem): number;
  36620. /**
  36621. * Remove a animation for the list of scene's animations
  36622. * @param toRemove defines the animation to remove
  36623. * @returns the index where the animation was in the animation list
  36624. */
  36625. removeAnimation(toRemove: Animation): number;
  36626. /**
  36627. * Will stop the animation of the given target
  36628. * @param target - the target
  36629. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36630. * @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)
  36631. */
  36632. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36633. /**
  36634. * Removes the given animation group from this scene.
  36635. * @param toRemove The animation group to remove
  36636. * @returns The index of the removed animation group
  36637. */
  36638. removeAnimationGroup(toRemove: AnimationGroup): number;
  36639. /**
  36640. * Removes the given multi-material from this scene.
  36641. * @param toRemove The multi-material to remove
  36642. * @returns The index of the removed multi-material
  36643. */
  36644. removeMultiMaterial(toRemove: MultiMaterial): number;
  36645. /**
  36646. * Removes the given material from this scene.
  36647. * @param toRemove The material to remove
  36648. * @returns The index of the removed material
  36649. */
  36650. removeMaterial(toRemove: Material): number;
  36651. /**
  36652. * Removes the given action manager from this scene.
  36653. * @param toRemove The action manager to remove
  36654. * @returns The index of the removed action manager
  36655. */
  36656. removeActionManager(toRemove: AbstractActionManager): number;
  36657. /**
  36658. * Removes the given texture from this scene.
  36659. * @param toRemove The texture to remove
  36660. * @returns The index of the removed texture
  36661. */
  36662. removeTexture(toRemove: BaseTexture): number;
  36663. /**
  36664. * Adds the given light to this scene
  36665. * @param newLight The light to add
  36666. */
  36667. addLight(newLight: Light): void;
  36668. /**
  36669. * Sorts the list list based on light priorities
  36670. */
  36671. sortLightsByPriority(): void;
  36672. /**
  36673. * Adds the given camera to this scene
  36674. * @param newCamera The camera to add
  36675. */
  36676. addCamera(newCamera: Camera): void;
  36677. /**
  36678. * Adds the given skeleton to this scene
  36679. * @param newSkeleton The skeleton to add
  36680. */
  36681. addSkeleton(newSkeleton: Skeleton): void;
  36682. /**
  36683. * Adds the given particle system to this scene
  36684. * @param newParticleSystem The particle system to add
  36685. */
  36686. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36687. /**
  36688. * Adds the given animation to this scene
  36689. * @param newAnimation The animation to add
  36690. */
  36691. addAnimation(newAnimation: Animation): void;
  36692. /**
  36693. * Adds the given animation group to this scene.
  36694. * @param newAnimationGroup The animation group to add
  36695. */
  36696. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36697. /**
  36698. * Adds the given multi-material to this scene
  36699. * @param newMultiMaterial The multi-material to add
  36700. */
  36701. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36702. /**
  36703. * Adds the given material to this scene
  36704. * @param newMaterial The material to add
  36705. */
  36706. addMaterial(newMaterial: Material): void;
  36707. /**
  36708. * Adds the given morph target to this scene
  36709. * @param newMorphTargetManager The morph target to add
  36710. */
  36711. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36712. /**
  36713. * Adds the given geometry to this scene
  36714. * @param newGeometry The geometry to add
  36715. */
  36716. addGeometry(newGeometry: Geometry): void;
  36717. /**
  36718. * Adds the given action manager to this scene
  36719. * @param newActionManager The action manager to add
  36720. */
  36721. addActionManager(newActionManager: AbstractActionManager): void;
  36722. /**
  36723. * Adds the given texture to this scene.
  36724. * @param newTexture The texture to add
  36725. */
  36726. addTexture(newTexture: BaseTexture): void;
  36727. /**
  36728. * Switch active camera
  36729. * @param newCamera defines the new active camera
  36730. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36731. */
  36732. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36733. /**
  36734. * sets the active camera of the scene using its ID
  36735. * @param id defines the camera's ID
  36736. * @return the new active camera or null if none found.
  36737. */
  36738. setActiveCameraByID(id: string): Nullable<Camera>;
  36739. /**
  36740. * sets the active camera of the scene using its name
  36741. * @param name defines the camera's name
  36742. * @returns the new active camera or null if none found.
  36743. */
  36744. setActiveCameraByName(name: string): Nullable<Camera>;
  36745. /**
  36746. * get an animation group using its name
  36747. * @param name defines the material's name
  36748. * @return the animation group or null if none found.
  36749. */
  36750. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36751. /**
  36752. * Get a material using its unique id
  36753. * @param uniqueId defines the material's unique id
  36754. * @return the material or null if none found.
  36755. */
  36756. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36757. /**
  36758. * get a material using its id
  36759. * @param id defines the material's ID
  36760. * @return the material or null if none found.
  36761. */
  36762. getMaterialByID(id: string): Nullable<Material>;
  36763. /**
  36764. * Gets a the last added material using a given id
  36765. * @param id defines the material's ID
  36766. * @return the last material with the given id or null if none found.
  36767. */
  36768. getLastMaterialByID(id: string): Nullable<Material>;
  36769. /**
  36770. * Gets a material using its name
  36771. * @param name defines the material's name
  36772. * @return the material or null if none found.
  36773. */
  36774. getMaterialByName(name: string): Nullable<Material>;
  36775. /**
  36776. * Get a texture using its unique id
  36777. * @param uniqueId defines the texture's unique id
  36778. * @return the texture or null if none found.
  36779. */
  36780. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36781. /**
  36782. * Gets a camera using its id
  36783. * @param id defines the id to look for
  36784. * @returns the camera or null if not found
  36785. */
  36786. getCameraByID(id: string): Nullable<Camera>;
  36787. /**
  36788. * Gets a camera using its unique id
  36789. * @param uniqueId defines the unique id to look for
  36790. * @returns the camera or null if not found
  36791. */
  36792. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36793. /**
  36794. * Gets a camera using its name
  36795. * @param name defines the camera's name
  36796. * @return the camera or null if none found.
  36797. */
  36798. getCameraByName(name: string): Nullable<Camera>;
  36799. /**
  36800. * Gets a bone using its id
  36801. * @param id defines the bone's id
  36802. * @return the bone or null if not found
  36803. */
  36804. getBoneByID(id: string): Nullable<Bone>;
  36805. /**
  36806. * Gets a bone using its id
  36807. * @param name defines the bone's name
  36808. * @return the bone or null if not found
  36809. */
  36810. getBoneByName(name: string): Nullable<Bone>;
  36811. /**
  36812. * Gets a light node using its name
  36813. * @param name defines the the light's name
  36814. * @return the light or null if none found.
  36815. */
  36816. getLightByName(name: string): Nullable<Light>;
  36817. /**
  36818. * Gets a light node using its id
  36819. * @param id defines the light's id
  36820. * @return the light or null if none found.
  36821. */
  36822. getLightByID(id: string): Nullable<Light>;
  36823. /**
  36824. * Gets a light node using its scene-generated unique ID
  36825. * @param uniqueId defines the light's unique id
  36826. * @return the light or null if none found.
  36827. */
  36828. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36829. /**
  36830. * Gets a particle system by id
  36831. * @param id defines the particle system id
  36832. * @return the corresponding system or null if none found
  36833. */
  36834. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36835. /**
  36836. * Gets a geometry using its ID
  36837. * @param id defines the geometry's id
  36838. * @return the geometry or null if none found.
  36839. */
  36840. getGeometryByID(id: string): Nullable<Geometry>;
  36841. private _getGeometryByUniqueID;
  36842. /**
  36843. * Add a new geometry to this scene
  36844. * @param geometry defines the geometry to be added to the scene.
  36845. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36846. * @return a boolean defining if the geometry was added or not
  36847. */
  36848. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36849. /**
  36850. * Removes an existing geometry
  36851. * @param geometry defines the geometry to be removed from the scene
  36852. * @return a boolean defining if the geometry was removed or not
  36853. */
  36854. removeGeometry(geometry: Geometry): boolean;
  36855. /**
  36856. * Gets the list of geometries attached to the scene
  36857. * @returns an array of Geometry
  36858. */
  36859. getGeometries(): Geometry[];
  36860. /**
  36861. * Gets the first added mesh found of a given ID
  36862. * @param id defines the id to search for
  36863. * @return the mesh found or null if not found at all
  36864. */
  36865. getMeshByID(id: string): Nullable<AbstractMesh>;
  36866. /**
  36867. * Gets a list of meshes using their id
  36868. * @param id defines the id to search for
  36869. * @returns a list of meshes
  36870. */
  36871. getMeshesByID(id: string): Array<AbstractMesh>;
  36872. /**
  36873. * Gets the first added transform node found of a given ID
  36874. * @param id defines the id to search for
  36875. * @return the found transform node or null if not found at all.
  36876. */
  36877. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36878. /**
  36879. * Gets a transform node with its auto-generated unique id
  36880. * @param uniqueId efines the unique id to search for
  36881. * @return the found transform node or null if not found at all.
  36882. */
  36883. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36884. /**
  36885. * Gets a list of transform nodes using their id
  36886. * @param id defines the id to search for
  36887. * @returns a list of transform nodes
  36888. */
  36889. getTransformNodesByID(id: string): Array<TransformNode>;
  36890. /**
  36891. * Gets a mesh with its auto-generated unique id
  36892. * @param uniqueId defines the unique id to search for
  36893. * @return the found mesh or null if not found at all.
  36894. */
  36895. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36896. /**
  36897. * Gets a the last added mesh using a given id
  36898. * @param id defines the id to search for
  36899. * @return the found mesh or null if not found at all.
  36900. */
  36901. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36902. /**
  36903. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36904. * @param id defines the id to search for
  36905. * @return the found node or null if not found at all
  36906. */
  36907. getLastEntryByID(id: string): Nullable<Node>;
  36908. /**
  36909. * Gets a node (Mesh, Camera, Light) using a given id
  36910. * @param id defines the id to search for
  36911. * @return the found node or null if not found at all
  36912. */
  36913. getNodeByID(id: string): Nullable<Node>;
  36914. /**
  36915. * Gets a node (Mesh, Camera, Light) using a given name
  36916. * @param name defines the name to search for
  36917. * @return the found node or null if not found at all.
  36918. */
  36919. getNodeByName(name: string): Nullable<Node>;
  36920. /**
  36921. * Gets a mesh using a given name
  36922. * @param name defines the name to search for
  36923. * @return the found mesh or null if not found at all.
  36924. */
  36925. getMeshByName(name: string): Nullable<AbstractMesh>;
  36926. /**
  36927. * Gets a transform node using a given name
  36928. * @param name defines the name to search for
  36929. * @return the found transform node or null if not found at all.
  36930. */
  36931. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36932. /**
  36933. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36934. * @param id defines the id to search for
  36935. * @return the found skeleton or null if not found at all.
  36936. */
  36937. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36938. /**
  36939. * Gets a skeleton using a given auto generated unique id
  36940. * @param uniqueId defines the unique id to search for
  36941. * @return the found skeleton or null if not found at all.
  36942. */
  36943. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36944. /**
  36945. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36946. * @param id defines the id to search for
  36947. * @return the found skeleton or null if not found at all.
  36948. */
  36949. getSkeletonById(id: string): Nullable<Skeleton>;
  36950. /**
  36951. * Gets a skeleton using a given name
  36952. * @param name defines the name to search for
  36953. * @return the found skeleton or null if not found at all.
  36954. */
  36955. getSkeletonByName(name: string): Nullable<Skeleton>;
  36956. /**
  36957. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36958. * @param id defines the id to search for
  36959. * @return the found morph target manager or null if not found at all.
  36960. */
  36961. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36962. /**
  36963. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36964. * @param id defines the id to search for
  36965. * @return the found morph target or null if not found at all.
  36966. */
  36967. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36968. /**
  36969. * Gets a boolean indicating if the given mesh is active
  36970. * @param mesh defines the mesh to look for
  36971. * @returns true if the mesh is in the active list
  36972. */
  36973. isActiveMesh(mesh: AbstractMesh): boolean;
  36974. /**
  36975. * Return a unique id as a string which can serve as an identifier for the scene
  36976. */
  36977. get uid(): string;
  36978. /**
  36979. * Add an externaly attached data from its key.
  36980. * This method call will fail and return false, if such key already exists.
  36981. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36982. * @param key the unique key that identifies the data
  36983. * @param data the data object to associate to the key for this Engine instance
  36984. * @return true if no such key were already present and the data was added successfully, false otherwise
  36985. */
  36986. addExternalData<T>(key: string, data: T): boolean;
  36987. /**
  36988. * Get an externaly attached data from its key
  36989. * @param key the unique key that identifies the data
  36990. * @return the associated data, if present (can be null), or undefined if not present
  36991. */
  36992. getExternalData<T>(key: string): Nullable<T>;
  36993. /**
  36994. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36995. * @param key the unique key that identifies the data
  36996. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36997. * @return the associated data, can be null if the factory returned null.
  36998. */
  36999. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37000. /**
  37001. * Remove an externaly attached data from the Engine instance
  37002. * @param key the unique key that identifies the data
  37003. * @return true if the data was successfully removed, false if it doesn't exist
  37004. */
  37005. removeExternalData(key: string): boolean;
  37006. private _evaluateSubMesh;
  37007. /**
  37008. * Clear the processed materials smart array preventing retention point in material dispose.
  37009. */
  37010. freeProcessedMaterials(): void;
  37011. private _preventFreeActiveMeshesAndRenderingGroups;
  37012. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37013. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37014. * when disposing several meshes in a row or a hierarchy of meshes.
  37015. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37016. */
  37017. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37018. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37019. /**
  37020. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37021. */
  37022. freeActiveMeshes(): void;
  37023. /**
  37024. * Clear the info related to rendering groups preventing retention points during dispose.
  37025. */
  37026. freeRenderingGroups(): void;
  37027. /** @hidden */
  37028. _isInIntermediateRendering(): boolean;
  37029. /**
  37030. * Lambda returning the list of potentially active meshes.
  37031. */
  37032. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37033. /**
  37034. * Lambda returning the list of potentially active sub meshes.
  37035. */
  37036. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37037. /**
  37038. * Lambda returning the list of potentially intersecting sub meshes.
  37039. */
  37040. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37041. /**
  37042. * Lambda returning the list of potentially colliding sub meshes.
  37043. */
  37044. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37045. private _activeMeshesFrozen;
  37046. private _skipEvaluateActiveMeshesCompletely;
  37047. /**
  37048. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37049. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37050. * @returns the current scene
  37051. */
  37052. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37053. /**
  37054. * Use this function to restart evaluating active meshes on every frame
  37055. * @returns the current scene
  37056. */
  37057. unfreezeActiveMeshes(): Scene;
  37058. private _evaluateActiveMeshes;
  37059. private _activeMesh;
  37060. /**
  37061. * Update the transform matrix to update from the current active camera
  37062. * @param force defines a boolean used to force the update even if cache is up to date
  37063. */
  37064. updateTransformMatrix(force?: boolean): void;
  37065. private _bindFrameBuffer;
  37066. /** @hidden */
  37067. _allowPostProcessClearColor: boolean;
  37068. /** @hidden */
  37069. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37070. private _processSubCameras;
  37071. private _checkIntersections;
  37072. /** @hidden */
  37073. _advancePhysicsEngineStep(step: number): void;
  37074. /**
  37075. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37076. */
  37077. getDeterministicFrameTime: () => number;
  37078. /** @hidden */
  37079. _animate(): void;
  37080. /** Execute all animations (for a frame) */
  37081. animate(): void;
  37082. /**
  37083. * Render the scene
  37084. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37085. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37086. */
  37087. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37088. /**
  37089. * Freeze all materials
  37090. * A frozen material will not be updatable but should be faster to render
  37091. */
  37092. freezeMaterials(): void;
  37093. /**
  37094. * Unfreeze all materials
  37095. * A frozen material will not be updatable but should be faster to render
  37096. */
  37097. unfreezeMaterials(): void;
  37098. /**
  37099. * Releases all held ressources
  37100. */
  37101. dispose(): void;
  37102. /**
  37103. * Gets if the scene is already disposed
  37104. */
  37105. get isDisposed(): boolean;
  37106. /**
  37107. * Call this function to reduce memory footprint of the scene.
  37108. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37109. */
  37110. clearCachedVertexData(): void;
  37111. /**
  37112. * This function will remove the local cached buffer data from texture.
  37113. * It will save memory but will prevent the texture from being rebuilt
  37114. */
  37115. cleanCachedTextureBuffer(): void;
  37116. /**
  37117. * Get the world extend vectors with an optional filter
  37118. *
  37119. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37120. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37121. */
  37122. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37123. min: Vector3;
  37124. max: Vector3;
  37125. };
  37126. /**
  37127. * Creates a ray that can be used to pick in the scene
  37128. * @param x defines the x coordinate of the origin (on-screen)
  37129. * @param y defines the y coordinate of the origin (on-screen)
  37130. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37131. * @param camera defines the camera to use for the picking
  37132. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37133. * @returns a Ray
  37134. */
  37135. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37136. /**
  37137. * Creates a ray that can be used to pick in the scene
  37138. * @param x defines the x coordinate of the origin (on-screen)
  37139. * @param y defines the y coordinate of the origin (on-screen)
  37140. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37141. * @param result defines the ray where to store the picking ray
  37142. * @param camera defines the camera to use for the picking
  37143. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37144. * @returns the current scene
  37145. */
  37146. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37147. /**
  37148. * Creates a ray that can be used to pick in the scene
  37149. * @param x defines the x coordinate of the origin (on-screen)
  37150. * @param y defines the y coordinate of the origin (on-screen)
  37151. * @param camera defines the camera to use for the picking
  37152. * @returns a Ray
  37153. */
  37154. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37155. /**
  37156. * Creates a ray that can be used to pick in the scene
  37157. * @param x defines the x coordinate of the origin (on-screen)
  37158. * @param y defines the y coordinate of the origin (on-screen)
  37159. * @param result defines the ray where to store the picking ray
  37160. * @param camera defines the camera to use for the picking
  37161. * @returns the current scene
  37162. */
  37163. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37164. /** Launch a ray to try to pick a mesh in the scene
  37165. * @param x position on screen
  37166. * @param y position on screen
  37167. * @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
  37168. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37169. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37170. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37171. * @returns a PickingInfo
  37172. */
  37173. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37174. /** Use the given ray to pick a mesh in the scene
  37175. * @param ray The ray to use to pick meshes
  37176. * @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
  37177. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37178. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37179. * @returns a PickingInfo
  37180. */
  37181. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37182. /**
  37183. * Launch a ray to try to pick a mesh in the scene
  37184. * @param x X position on screen
  37185. * @param y Y position on screen
  37186. * @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
  37187. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37189. * @returns an array of PickingInfo
  37190. */
  37191. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37192. /**
  37193. * Launch a ray to try to pick a mesh in the scene
  37194. * @param ray Ray to use
  37195. * @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
  37196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37197. * @returns an array of PickingInfo
  37198. */
  37199. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37200. /**
  37201. * Force the value of meshUnderPointer
  37202. * @param mesh defines the mesh to use
  37203. */
  37204. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37205. /**
  37206. * Gets the mesh under the pointer
  37207. * @returns a Mesh or null if no mesh is under the pointer
  37208. */
  37209. getPointerOverMesh(): Nullable<AbstractMesh>;
  37210. /** @hidden */
  37211. _rebuildGeometries(): void;
  37212. /** @hidden */
  37213. _rebuildTextures(): void;
  37214. private _getByTags;
  37215. /**
  37216. * Get a list of meshes by tags
  37217. * @param tagsQuery defines the tags query to use
  37218. * @param forEach defines a predicate used to filter results
  37219. * @returns an array of Mesh
  37220. */
  37221. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37222. /**
  37223. * Get a list of cameras by tags
  37224. * @param tagsQuery defines the tags query to use
  37225. * @param forEach defines a predicate used to filter results
  37226. * @returns an array of Camera
  37227. */
  37228. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37229. /**
  37230. * Get a list of lights by tags
  37231. * @param tagsQuery defines the tags query to use
  37232. * @param forEach defines a predicate used to filter results
  37233. * @returns an array of Light
  37234. */
  37235. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37236. /**
  37237. * Get a list of materials by tags
  37238. * @param tagsQuery defines the tags query to use
  37239. * @param forEach defines a predicate used to filter results
  37240. * @returns an array of Material
  37241. */
  37242. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37243. /**
  37244. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37245. * This allowed control for front to back rendering or reversly depending of the special needs.
  37246. *
  37247. * @param renderingGroupId The rendering group id corresponding to its index
  37248. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37249. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37250. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37251. */
  37252. 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;
  37253. /**
  37254. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37255. *
  37256. * @param renderingGroupId The rendering group id corresponding to its index
  37257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37258. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37259. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37260. */
  37261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37262. /**
  37263. * Gets the current auto clear configuration for one rendering group of the rendering
  37264. * manager.
  37265. * @param index the rendering group index to get the information for
  37266. * @returns The auto clear setup for the requested rendering group
  37267. */
  37268. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37269. private _blockMaterialDirtyMechanism;
  37270. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37271. get blockMaterialDirtyMechanism(): boolean;
  37272. set blockMaterialDirtyMechanism(value: boolean);
  37273. /**
  37274. * Will flag all materials as dirty to trigger new shader compilation
  37275. * @param flag defines the flag used to specify which material part must be marked as dirty
  37276. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37277. */
  37278. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37279. /** @hidden */
  37280. _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;
  37281. /** @hidden */
  37282. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37283. /** @hidden */
  37284. _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;
  37285. /** @hidden */
  37286. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37287. /** @hidden */
  37288. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37289. /** @hidden */
  37290. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37291. }
  37292. }
  37293. declare module BABYLON {
  37294. /**
  37295. * Set of assets to keep when moving a scene into an asset container.
  37296. */
  37297. export class KeepAssets extends AbstractScene {
  37298. }
  37299. /**
  37300. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37301. */
  37302. export class InstantiatedEntries {
  37303. /**
  37304. * List of new root nodes (eg. nodes with no parent)
  37305. */
  37306. rootNodes: TransformNode[];
  37307. /**
  37308. * List of new skeletons
  37309. */
  37310. skeletons: Skeleton[];
  37311. /**
  37312. * List of new animation groups
  37313. */
  37314. animationGroups: AnimationGroup[];
  37315. }
  37316. /**
  37317. * Container with a set of assets that can be added or removed from a scene.
  37318. */
  37319. export class AssetContainer extends AbstractScene {
  37320. private _wasAddedToScene;
  37321. /**
  37322. * The scene the AssetContainer belongs to.
  37323. */
  37324. scene: Scene;
  37325. /**
  37326. * Instantiates an AssetContainer.
  37327. * @param scene The scene the AssetContainer belongs to.
  37328. */
  37329. constructor(scene: Scene);
  37330. /**
  37331. * Instantiate or clone all meshes and add the new ones to the scene.
  37332. * Skeletons and animation groups will all be cloned
  37333. * @param nameFunction defines an optional function used to get new names for clones
  37334. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37335. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37336. */
  37337. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37338. /**
  37339. * Adds all the assets from the container to the scene.
  37340. */
  37341. addAllToScene(): void;
  37342. /**
  37343. * Removes all the assets in the container from the scene
  37344. */
  37345. removeAllFromScene(): void;
  37346. /**
  37347. * Disposes all the assets in the container
  37348. */
  37349. dispose(): void;
  37350. private _moveAssets;
  37351. /**
  37352. * Removes all the assets contained in the scene and adds them to the container.
  37353. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37354. */
  37355. moveAllFromScene(keepAssets?: KeepAssets): void;
  37356. /**
  37357. * 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.
  37358. * @returns the root mesh
  37359. */
  37360. createRootMesh(): Mesh;
  37361. /**
  37362. * Merge animations from this asset container into a scene
  37363. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37364. * @param animatables set of animatables to retarget to a node from the scene
  37365. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37366. */
  37367. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37368. }
  37369. }
  37370. declare module BABYLON {
  37371. /**
  37372. * Defines how the parser contract is defined.
  37373. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37374. */
  37375. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37376. /**
  37377. * Defines how the individual parser contract is defined.
  37378. * These parser can parse an individual asset
  37379. */
  37380. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37381. /**
  37382. * Base class of the scene acting as a container for the different elements composing a scene.
  37383. * This class is dynamically extended by the different components of the scene increasing
  37384. * flexibility and reducing coupling
  37385. */
  37386. export abstract class AbstractScene {
  37387. /**
  37388. * Stores the list of available parsers in the application.
  37389. */
  37390. private static _BabylonFileParsers;
  37391. /**
  37392. * Stores the list of available individual parsers in the application.
  37393. */
  37394. private static _IndividualBabylonFileParsers;
  37395. /**
  37396. * Adds a parser in the list of available ones
  37397. * @param name Defines the name of the parser
  37398. * @param parser Defines the parser to add
  37399. */
  37400. static AddParser(name: string, parser: BabylonFileParser): void;
  37401. /**
  37402. * Gets a general parser from the list of avaialble ones
  37403. * @param name Defines the name of the parser
  37404. * @returns the requested parser or null
  37405. */
  37406. static GetParser(name: string): Nullable<BabylonFileParser>;
  37407. /**
  37408. * Adds n individual parser in the list of available ones
  37409. * @param name Defines the name of the parser
  37410. * @param parser Defines the parser to add
  37411. */
  37412. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37413. /**
  37414. * Gets an individual parser from the list of avaialble ones
  37415. * @param name Defines the name of the parser
  37416. * @returns the requested parser or null
  37417. */
  37418. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37419. /**
  37420. * Parser json data and populate both a scene and its associated container object
  37421. * @param jsonData Defines the data to parse
  37422. * @param scene Defines the scene to parse the data for
  37423. * @param container Defines the container attached to the parsing sequence
  37424. * @param rootUrl Defines the root url of the data
  37425. */
  37426. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37427. /**
  37428. * Gets the list of root nodes (ie. nodes with no parent)
  37429. */
  37430. rootNodes: Node[];
  37431. /** All of the cameras added to this scene
  37432. * @see http://doc.babylonjs.com/babylon101/cameras
  37433. */
  37434. cameras: Camera[];
  37435. /**
  37436. * All of the lights added to this scene
  37437. * @see http://doc.babylonjs.com/babylon101/lights
  37438. */
  37439. lights: Light[];
  37440. /**
  37441. * All of the (abstract) meshes added to this scene
  37442. */
  37443. meshes: AbstractMesh[];
  37444. /**
  37445. * The list of skeletons added to the scene
  37446. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37447. */
  37448. skeletons: Skeleton[];
  37449. /**
  37450. * All of the particle systems added to this scene
  37451. * @see http://doc.babylonjs.com/babylon101/particles
  37452. */
  37453. particleSystems: IParticleSystem[];
  37454. /**
  37455. * Gets a list of Animations associated with the scene
  37456. */
  37457. animations: Animation[];
  37458. /**
  37459. * All of the animation groups added to this scene
  37460. * @see http://doc.babylonjs.com/how_to/group
  37461. */
  37462. animationGroups: AnimationGroup[];
  37463. /**
  37464. * All of the multi-materials added to this scene
  37465. * @see http://doc.babylonjs.com/how_to/multi_materials
  37466. */
  37467. multiMaterials: MultiMaterial[];
  37468. /**
  37469. * All of the materials added to this scene
  37470. * In the context of a Scene, it is not supposed to be modified manually.
  37471. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37472. * Note also that the order of the Material within the array is not significant and might change.
  37473. * @see http://doc.babylonjs.com/babylon101/materials
  37474. */
  37475. materials: Material[];
  37476. /**
  37477. * The list of morph target managers added to the scene
  37478. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37479. */
  37480. morphTargetManagers: MorphTargetManager[];
  37481. /**
  37482. * The list of geometries used in the scene.
  37483. */
  37484. geometries: Geometry[];
  37485. /**
  37486. * All of the tranform nodes added to this scene
  37487. * In the context of a Scene, it is not supposed to be modified manually.
  37488. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37489. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37490. * @see http://doc.babylonjs.com/how_to/transformnode
  37491. */
  37492. transformNodes: TransformNode[];
  37493. /**
  37494. * ActionManagers available on the scene.
  37495. */
  37496. actionManagers: AbstractActionManager[];
  37497. /**
  37498. * Textures to keep.
  37499. */
  37500. textures: BaseTexture[];
  37501. /**
  37502. * Environment texture for the scene
  37503. */
  37504. environmentTexture: Nullable<BaseTexture>;
  37505. /**
  37506. * @returns all meshes, lights, cameras, transformNodes and bones
  37507. */
  37508. getNodes(): Array<Node>;
  37509. }
  37510. }
  37511. declare module BABYLON {
  37512. /**
  37513. * Interface used to define options for Sound class
  37514. */
  37515. export interface ISoundOptions {
  37516. /**
  37517. * Does the sound autoplay once loaded.
  37518. */
  37519. autoplay?: boolean;
  37520. /**
  37521. * Does the sound loop after it finishes playing once.
  37522. */
  37523. loop?: boolean;
  37524. /**
  37525. * Sound's volume
  37526. */
  37527. volume?: number;
  37528. /**
  37529. * Is it a spatial sound?
  37530. */
  37531. spatialSound?: boolean;
  37532. /**
  37533. * Maximum distance to hear that sound
  37534. */
  37535. maxDistance?: number;
  37536. /**
  37537. * Uses user defined attenuation function
  37538. */
  37539. useCustomAttenuation?: boolean;
  37540. /**
  37541. * Define the roll off factor of spatial sounds.
  37542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37543. */
  37544. rolloffFactor?: number;
  37545. /**
  37546. * Define the reference distance the sound should be heard perfectly.
  37547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37548. */
  37549. refDistance?: number;
  37550. /**
  37551. * Define the distance attenuation model the sound will follow.
  37552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37553. */
  37554. distanceModel?: string;
  37555. /**
  37556. * Defines the playback speed (1 by default)
  37557. */
  37558. playbackRate?: number;
  37559. /**
  37560. * Defines if the sound is from a streaming source
  37561. */
  37562. streaming?: boolean;
  37563. /**
  37564. * Defines an optional length (in seconds) inside the sound file
  37565. */
  37566. length?: number;
  37567. /**
  37568. * Defines an optional offset (in seconds) inside the sound file
  37569. */
  37570. offset?: number;
  37571. /**
  37572. * If true, URLs will not be required to state the audio file codec to use.
  37573. */
  37574. skipCodecCheck?: boolean;
  37575. }
  37576. /**
  37577. * Defines a sound that can be played in the application.
  37578. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37580. */
  37581. export class Sound {
  37582. /**
  37583. * The name of the sound in the scene.
  37584. */
  37585. name: string;
  37586. /**
  37587. * Does the sound autoplay once loaded.
  37588. */
  37589. autoplay: boolean;
  37590. /**
  37591. * Does the sound loop after it finishes playing once.
  37592. */
  37593. loop: boolean;
  37594. /**
  37595. * Does the sound use a custom attenuation curve to simulate the falloff
  37596. * happening when the source gets further away from the camera.
  37597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37598. */
  37599. useCustomAttenuation: boolean;
  37600. /**
  37601. * The sound track id this sound belongs to.
  37602. */
  37603. soundTrackId: number;
  37604. /**
  37605. * Is this sound currently played.
  37606. */
  37607. isPlaying: boolean;
  37608. /**
  37609. * Is this sound currently paused.
  37610. */
  37611. isPaused: boolean;
  37612. /**
  37613. * Does this sound enables spatial sound.
  37614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37615. */
  37616. spatialSound: boolean;
  37617. /**
  37618. * Define the reference distance the sound should be heard perfectly.
  37619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37620. */
  37621. refDistance: number;
  37622. /**
  37623. * Define the roll off factor of spatial sounds.
  37624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37625. */
  37626. rolloffFactor: number;
  37627. /**
  37628. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37630. */
  37631. maxDistance: number;
  37632. /**
  37633. * Define the distance attenuation model the sound will follow.
  37634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37635. */
  37636. distanceModel: string;
  37637. /**
  37638. * @hidden
  37639. * Back Compat
  37640. **/
  37641. onended: () => any;
  37642. /**
  37643. * Observable event when the current playing sound finishes.
  37644. */
  37645. onEndedObservable: Observable<Sound>;
  37646. private _panningModel;
  37647. private _playbackRate;
  37648. private _streaming;
  37649. private _startTime;
  37650. private _startOffset;
  37651. private _position;
  37652. /** @hidden */
  37653. _positionInEmitterSpace: boolean;
  37654. private _localDirection;
  37655. private _volume;
  37656. private _isReadyToPlay;
  37657. private _isDirectional;
  37658. private _readyToPlayCallback;
  37659. private _audioBuffer;
  37660. private _soundSource;
  37661. private _streamingSource;
  37662. private _soundPanner;
  37663. private _soundGain;
  37664. private _inputAudioNode;
  37665. private _outputAudioNode;
  37666. private _coneInnerAngle;
  37667. private _coneOuterAngle;
  37668. private _coneOuterGain;
  37669. private _scene;
  37670. private _connectedTransformNode;
  37671. private _customAttenuationFunction;
  37672. private _registerFunc;
  37673. private _isOutputConnected;
  37674. private _htmlAudioElement;
  37675. private _urlType;
  37676. private _length?;
  37677. private _offset?;
  37678. /** @hidden */
  37679. static _SceneComponentInitialization: (scene: Scene) => void;
  37680. /**
  37681. * Create a sound and attach it to a scene
  37682. * @param name Name of your sound
  37683. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37684. * @param scene defines the scene the sound belongs to
  37685. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37686. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37687. */
  37688. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37689. /**
  37690. * Release the sound and its associated resources
  37691. */
  37692. dispose(): void;
  37693. /**
  37694. * Gets if the sounds is ready to be played or not.
  37695. * @returns true if ready, otherwise false
  37696. */
  37697. isReady(): boolean;
  37698. private _soundLoaded;
  37699. /**
  37700. * Sets the data of the sound from an audiobuffer
  37701. * @param audioBuffer The audioBuffer containing the data
  37702. */
  37703. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37704. /**
  37705. * Updates the current sounds options such as maxdistance, loop...
  37706. * @param options A JSON object containing values named as the object properties
  37707. */
  37708. updateOptions(options: ISoundOptions): void;
  37709. private _createSpatialParameters;
  37710. private _updateSpatialParameters;
  37711. /**
  37712. * Switch the panning model to HRTF:
  37713. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37715. */
  37716. switchPanningModelToHRTF(): void;
  37717. /**
  37718. * Switch the panning model to Equal Power:
  37719. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37721. */
  37722. switchPanningModelToEqualPower(): void;
  37723. private _switchPanningModel;
  37724. /**
  37725. * Connect this sound to a sound track audio node like gain...
  37726. * @param soundTrackAudioNode the sound track audio node to connect to
  37727. */
  37728. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37729. /**
  37730. * Transform this sound into a directional source
  37731. * @param coneInnerAngle Size of the inner cone in degree
  37732. * @param coneOuterAngle Size of the outer cone in degree
  37733. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37734. */
  37735. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37736. /**
  37737. * Gets or sets the inner angle for the directional cone.
  37738. */
  37739. get directionalConeInnerAngle(): number;
  37740. /**
  37741. * Gets or sets the inner angle for the directional cone.
  37742. */
  37743. set directionalConeInnerAngle(value: number);
  37744. /**
  37745. * Gets or sets the outer angle for the directional cone.
  37746. */
  37747. get directionalConeOuterAngle(): number;
  37748. /**
  37749. * Gets or sets the outer angle for the directional cone.
  37750. */
  37751. set directionalConeOuterAngle(value: number);
  37752. /**
  37753. * Sets the position of the emitter if spatial sound is enabled
  37754. * @param newPosition Defines the new posisiton
  37755. */
  37756. setPosition(newPosition: Vector3): void;
  37757. /**
  37758. * Sets the local direction of the emitter if spatial sound is enabled
  37759. * @param newLocalDirection Defines the new local direction
  37760. */
  37761. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37762. private _updateDirection;
  37763. /** @hidden */
  37764. updateDistanceFromListener(): void;
  37765. /**
  37766. * Sets a new custom attenuation function for the sound.
  37767. * @param callback Defines the function used for the attenuation
  37768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37769. */
  37770. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37771. /**
  37772. * Play the sound
  37773. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37774. * @param offset (optional) Start the sound at a specific time in seconds
  37775. * @param length (optional) Sound duration (in seconds)
  37776. */
  37777. play(time?: number, offset?: number, length?: number): void;
  37778. private _onended;
  37779. /**
  37780. * Stop the sound
  37781. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37782. */
  37783. stop(time?: number): void;
  37784. /**
  37785. * Put the sound in pause
  37786. */
  37787. pause(): void;
  37788. /**
  37789. * Sets a dedicated volume for this sounds
  37790. * @param newVolume Define the new volume of the sound
  37791. * @param time Define time for gradual change to new volume
  37792. */
  37793. setVolume(newVolume: number, time?: number): void;
  37794. /**
  37795. * Set the sound play back rate
  37796. * @param newPlaybackRate Define the playback rate the sound should be played at
  37797. */
  37798. setPlaybackRate(newPlaybackRate: number): void;
  37799. /**
  37800. * Gets the volume of the sound.
  37801. * @returns the volume of the sound
  37802. */
  37803. getVolume(): number;
  37804. /**
  37805. * Attach the sound to a dedicated mesh
  37806. * @param transformNode The transform node to connect the sound with
  37807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37808. */
  37809. attachToMesh(transformNode: TransformNode): void;
  37810. /**
  37811. * Detach the sound from the previously attached mesh
  37812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37813. */
  37814. detachFromMesh(): void;
  37815. private _onRegisterAfterWorldMatrixUpdate;
  37816. /**
  37817. * Clone the current sound in the scene.
  37818. * @returns the new sound clone
  37819. */
  37820. clone(): Nullable<Sound>;
  37821. /**
  37822. * Gets the current underlying audio buffer containing the data
  37823. * @returns the audio buffer
  37824. */
  37825. getAudioBuffer(): Nullable<AudioBuffer>;
  37826. /**
  37827. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37828. * @returns the source node
  37829. */
  37830. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37831. /**
  37832. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37833. * @returns the gain node
  37834. */
  37835. getSoundGain(): Nullable<GainNode>;
  37836. /**
  37837. * Serializes the Sound in a JSON representation
  37838. * @returns the JSON representation of the sound
  37839. */
  37840. serialize(): any;
  37841. /**
  37842. * Parse a JSON representation of a sound to innstantiate in a given scene
  37843. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37844. * @param scene Define the scene the new parsed sound should be created in
  37845. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37846. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37847. * @returns the newly parsed sound
  37848. */
  37849. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37850. }
  37851. }
  37852. declare module BABYLON {
  37853. /**
  37854. * This defines an action helpful to play a defined sound on a triggered action.
  37855. */
  37856. export class PlaySoundAction extends Action {
  37857. private _sound;
  37858. /**
  37859. * Instantiate the action
  37860. * @param triggerOptions defines the trigger options
  37861. * @param sound defines the sound to play
  37862. * @param condition defines the trigger related conditions
  37863. */
  37864. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37865. /** @hidden */
  37866. _prepare(): void;
  37867. /**
  37868. * Execute the action and play the sound.
  37869. */
  37870. execute(): void;
  37871. /**
  37872. * Serializes the actions and its related information.
  37873. * @param parent defines the object to serialize in
  37874. * @returns the serialized object
  37875. */
  37876. serialize(parent: any): any;
  37877. }
  37878. /**
  37879. * This defines an action helpful to stop a defined sound on a triggered action.
  37880. */
  37881. export class StopSoundAction extends Action {
  37882. private _sound;
  37883. /**
  37884. * Instantiate the action
  37885. * @param triggerOptions defines the trigger options
  37886. * @param sound defines the sound to stop
  37887. * @param condition defines the trigger related conditions
  37888. */
  37889. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37890. /** @hidden */
  37891. _prepare(): void;
  37892. /**
  37893. * Execute the action and stop the sound.
  37894. */
  37895. execute(): void;
  37896. /**
  37897. * Serializes the actions and its related information.
  37898. * @param parent defines the object to serialize in
  37899. * @returns the serialized object
  37900. */
  37901. serialize(parent: any): any;
  37902. }
  37903. }
  37904. declare module BABYLON {
  37905. /**
  37906. * This defines an action responsible to change the value of a property
  37907. * by interpolating between its current value and the newly set one once triggered.
  37908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37909. */
  37910. export class InterpolateValueAction extends Action {
  37911. /**
  37912. * Defines the path of the property where the value should be interpolated
  37913. */
  37914. propertyPath: string;
  37915. /**
  37916. * Defines the target value at the end of the interpolation.
  37917. */
  37918. value: any;
  37919. /**
  37920. * Defines the time it will take for the property to interpolate to the value.
  37921. */
  37922. duration: number;
  37923. /**
  37924. * Defines if the other scene animations should be stopped when the action has been triggered
  37925. */
  37926. stopOtherAnimations?: boolean;
  37927. /**
  37928. * Defines a callback raised once the interpolation animation has been done.
  37929. */
  37930. onInterpolationDone?: () => void;
  37931. /**
  37932. * Observable triggered once the interpolation animation has been done.
  37933. */
  37934. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37935. private _target;
  37936. private _effectiveTarget;
  37937. private _property;
  37938. /**
  37939. * Instantiate the action
  37940. * @param triggerOptions defines the trigger options
  37941. * @param target defines the object containing the value to interpolate
  37942. * @param propertyPath defines the path to the property in the target object
  37943. * @param value defines the target value at the end of the interpolation
  37944. * @param duration deines the time it will take for the property to interpolate to the value.
  37945. * @param condition defines the trigger related conditions
  37946. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37947. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37948. */
  37949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37950. /** @hidden */
  37951. _prepare(): void;
  37952. /**
  37953. * Execute the action starts the value interpolation.
  37954. */
  37955. execute(): void;
  37956. /**
  37957. * Serializes the actions and its related information.
  37958. * @param parent defines the object to serialize in
  37959. * @returns the serialized object
  37960. */
  37961. serialize(parent: any): any;
  37962. }
  37963. }
  37964. declare module BABYLON {
  37965. /**
  37966. * Options allowed during the creation of a sound track.
  37967. */
  37968. export interface ISoundTrackOptions {
  37969. /**
  37970. * The volume the sound track should take during creation
  37971. */
  37972. volume?: number;
  37973. /**
  37974. * Define if the sound track is the main sound track of the scene
  37975. */
  37976. mainTrack?: boolean;
  37977. }
  37978. /**
  37979. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37980. * It will be also used in a future release to apply effects on a specific track.
  37981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37982. */
  37983. export class SoundTrack {
  37984. /**
  37985. * The unique identifier of the sound track in the scene.
  37986. */
  37987. id: number;
  37988. /**
  37989. * The list of sounds included in the sound track.
  37990. */
  37991. soundCollection: Array<Sound>;
  37992. private _outputAudioNode;
  37993. private _scene;
  37994. private _connectedAnalyser;
  37995. private _options;
  37996. private _isInitialized;
  37997. /**
  37998. * Creates a new sound track.
  37999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38000. * @param scene Define the scene the sound track belongs to
  38001. * @param options
  38002. */
  38003. constructor(scene: Scene, options?: ISoundTrackOptions);
  38004. private _initializeSoundTrackAudioGraph;
  38005. /**
  38006. * Release the sound track and its associated resources
  38007. */
  38008. dispose(): void;
  38009. /**
  38010. * Adds a sound to this sound track
  38011. * @param sound define the cound to add
  38012. * @ignoreNaming
  38013. */
  38014. AddSound(sound: Sound): void;
  38015. /**
  38016. * Removes a sound to this sound track
  38017. * @param sound define the cound to remove
  38018. * @ignoreNaming
  38019. */
  38020. RemoveSound(sound: Sound): void;
  38021. /**
  38022. * Set a global volume for the full sound track.
  38023. * @param newVolume Define the new volume of the sound track
  38024. */
  38025. setVolume(newVolume: number): void;
  38026. /**
  38027. * Switch the panning model to HRTF:
  38028. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38030. */
  38031. switchPanningModelToHRTF(): void;
  38032. /**
  38033. * Switch the panning model to Equal Power:
  38034. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38036. */
  38037. switchPanningModelToEqualPower(): void;
  38038. /**
  38039. * Connect the sound track to an audio analyser allowing some amazing
  38040. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38042. * @param analyser The analyser to connect to the engine
  38043. */
  38044. connectToAnalyser(analyser: Analyser): void;
  38045. }
  38046. }
  38047. declare module BABYLON {
  38048. interface AbstractScene {
  38049. /**
  38050. * The list of sounds used in the scene.
  38051. */
  38052. sounds: Nullable<Array<Sound>>;
  38053. }
  38054. interface Scene {
  38055. /**
  38056. * @hidden
  38057. * Backing field
  38058. */
  38059. _mainSoundTrack: SoundTrack;
  38060. /**
  38061. * The main sound track played by the scene.
  38062. * It cotains your primary collection of sounds.
  38063. */
  38064. mainSoundTrack: SoundTrack;
  38065. /**
  38066. * The list of sound tracks added to the scene
  38067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38068. */
  38069. soundTracks: Nullable<Array<SoundTrack>>;
  38070. /**
  38071. * Gets a sound using a given name
  38072. * @param name defines the name to search for
  38073. * @return the found sound or null if not found at all.
  38074. */
  38075. getSoundByName(name: string): Nullable<Sound>;
  38076. /**
  38077. * Gets or sets if audio support is enabled
  38078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38079. */
  38080. audioEnabled: boolean;
  38081. /**
  38082. * Gets or sets if audio will be output to headphones
  38083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38084. */
  38085. headphone: boolean;
  38086. /**
  38087. * Gets or sets custom audio listener position provider
  38088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38089. */
  38090. audioListenerPositionProvider: Nullable<() => Vector3>;
  38091. /**
  38092. * Gets or sets a refresh rate when using 3D audio positioning
  38093. */
  38094. audioPositioningRefreshRate: number;
  38095. }
  38096. /**
  38097. * Defines the sound scene component responsible to manage any sounds
  38098. * in a given scene.
  38099. */
  38100. export class AudioSceneComponent implements ISceneSerializableComponent {
  38101. /**
  38102. * The component name helpfull to identify the component in the list of scene components.
  38103. */
  38104. readonly name: string;
  38105. /**
  38106. * The scene the component belongs to.
  38107. */
  38108. scene: Scene;
  38109. private _audioEnabled;
  38110. /**
  38111. * Gets whether audio is enabled or not.
  38112. * Please use related enable/disable method to switch state.
  38113. */
  38114. get audioEnabled(): boolean;
  38115. private _headphone;
  38116. /**
  38117. * Gets whether audio is outputing to headphone or not.
  38118. * Please use the according Switch methods to change output.
  38119. */
  38120. get headphone(): boolean;
  38121. /**
  38122. * Gets or sets a refresh rate when using 3D audio positioning
  38123. */
  38124. audioPositioningRefreshRate: number;
  38125. private _audioListenerPositionProvider;
  38126. /**
  38127. * Gets the current audio listener position provider
  38128. */
  38129. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38130. /**
  38131. * Sets a custom listener position for all sounds in the scene
  38132. * By default, this is the position of the first active camera
  38133. */
  38134. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38135. /**
  38136. * Creates a new instance of the component for the given scene
  38137. * @param scene Defines the scene to register the component in
  38138. */
  38139. constructor(scene: Scene);
  38140. /**
  38141. * Registers the component in a given scene
  38142. */
  38143. register(): void;
  38144. /**
  38145. * Rebuilds the elements related to this component in case of
  38146. * context lost for instance.
  38147. */
  38148. rebuild(): void;
  38149. /**
  38150. * Serializes the component data to the specified json object
  38151. * @param serializationObject The object to serialize to
  38152. */
  38153. serialize(serializationObject: any): void;
  38154. /**
  38155. * Adds all the elements from the container to the scene
  38156. * @param container the container holding the elements
  38157. */
  38158. addFromContainer(container: AbstractScene): void;
  38159. /**
  38160. * Removes all the elements in the container from the scene
  38161. * @param container contains the elements to remove
  38162. * @param dispose if the removed element should be disposed (default: false)
  38163. */
  38164. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38165. /**
  38166. * Disposes the component and the associated ressources.
  38167. */
  38168. dispose(): void;
  38169. /**
  38170. * Disables audio in the associated scene.
  38171. */
  38172. disableAudio(): void;
  38173. /**
  38174. * Enables audio in the associated scene.
  38175. */
  38176. enableAudio(): void;
  38177. /**
  38178. * Switch audio to headphone output.
  38179. */
  38180. switchAudioModeForHeadphones(): void;
  38181. /**
  38182. * Switch audio to normal speakers.
  38183. */
  38184. switchAudioModeForNormalSpeakers(): void;
  38185. private _cachedCameraDirection;
  38186. private _cachedCameraPosition;
  38187. private _lastCheck;
  38188. private _afterRender;
  38189. }
  38190. }
  38191. declare module BABYLON {
  38192. /**
  38193. * Wraps one or more Sound objects and selects one with random weight for playback.
  38194. */
  38195. export class WeightedSound {
  38196. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38197. loop: boolean;
  38198. private _coneInnerAngle;
  38199. private _coneOuterAngle;
  38200. private _volume;
  38201. /** A Sound is currently playing. */
  38202. isPlaying: boolean;
  38203. /** A Sound is currently paused. */
  38204. isPaused: boolean;
  38205. private _sounds;
  38206. private _weights;
  38207. private _currentIndex?;
  38208. /**
  38209. * Creates a new WeightedSound from the list of sounds given.
  38210. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38211. * @param sounds Array of Sounds that will be selected from.
  38212. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38213. */
  38214. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38215. /**
  38216. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38217. */
  38218. get directionalConeInnerAngle(): number;
  38219. /**
  38220. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38221. */
  38222. set directionalConeInnerAngle(value: number);
  38223. /**
  38224. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38225. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38226. */
  38227. get directionalConeOuterAngle(): number;
  38228. /**
  38229. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38230. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38231. */
  38232. set directionalConeOuterAngle(value: number);
  38233. /**
  38234. * Playback volume.
  38235. */
  38236. get volume(): number;
  38237. /**
  38238. * Playback volume.
  38239. */
  38240. set volume(value: number);
  38241. private _onended;
  38242. /**
  38243. * Suspend playback
  38244. */
  38245. pause(): void;
  38246. /**
  38247. * Stop playback
  38248. */
  38249. stop(): void;
  38250. /**
  38251. * Start playback.
  38252. * @param startOffset Position the clip head at a specific time in seconds.
  38253. */
  38254. play(startOffset?: number): void;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38261. */
  38262. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38263. /**
  38264. * Gets the name of the behavior.
  38265. */
  38266. get name(): string;
  38267. /**
  38268. * The easing function used by animations
  38269. */
  38270. static EasingFunction: BackEase;
  38271. /**
  38272. * The easing mode used by animations
  38273. */
  38274. static EasingMode: number;
  38275. /**
  38276. * The duration of the animation, in milliseconds
  38277. */
  38278. transitionDuration: number;
  38279. /**
  38280. * Length of the distance animated by the transition when lower radius is reached
  38281. */
  38282. lowerRadiusTransitionRange: number;
  38283. /**
  38284. * Length of the distance animated by the transition when upper radius is reached
  38285. */
  38286. upperRadiusTransitionRange: number;
  38287. private _autoTransitionRange;
  38288. /**
  38289. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38290. */
  38291. get autoTransitionRange(): boolean;
  38292. /**
  38293. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38294. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38295. */
  38296. set autoTransitionRange(value: boolean);
  38297. private _attachedCamera;
  38298. private _onAfterCheckInputsObserver;
  38299. private _onMeshTargetChangedObserver;
  38300. /**
  38301. * Initializes the behavior.
  38302. */
  38303. init(): void;
  38304. /**
  38305. * Attaches the behavior to its arc rotate camera.
  38306. * @param camera Defines the camera to attach the behavior to
  38307. */
  38308. attach(camera: ArcRotateCamera): void;
  38309. /**
  38310. * Detaches the behavior from its current arc rotate camera.
  38311. */
  38312. detach(): void;
  38313. private _radiusIsAnimating;
  38314. private _radiusBounceTransition;
  38315. private _animatables;
  38316. private _cachedWheelPrecision;
  38317. /**
  38318. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38319. * @param radiusLimit The limit to check against.
  38320. * @return Bool to indicate if at limit.
  38321. */
  38322. private _isRadiusAtLimit;
  38323. /**
  38324. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38325. * @param radiusDelta The delta by which to animate to. Can be negative.
  38326. */
  38327. private _applyBoundRadiusAnimation;
  38328. /**
  38329. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38330. */
  38331. protected _clearAnimationLocks(): void;
  38332. /**
  38333. * Stops and removes all animations that have been applied to the camera
  38334. */
  38335. stopAllAnimations(): void;
  38336. }
  38337. }
  38338. declare module BABYLON {
  38339. /**
  38340. * 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.
  38341. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38342. */
  38343. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38344. /**
  38345. * Gets the name of the behavior.
  38346. */
  38347. get name(): string;
  38348. private _mode;
  38349. private _radiusScale;
  38350. private _positionScale;
  38351. private _defaultElevation;
  38352. private _elevationReturnTime;
  38353. private _elevationReturnWaitTime;
  38354. private _zoomStopsAnimation;
  38355. private _framingTime;
  38356. /**
  38357. * The easing function used by animations
  38358. */
  38359. static EasingFunction: ExponentialEase;
  38360. /**
  38361. * The easing mode used by animations
  38362. */
  38363. static EasingMode: number;
  38364. /**
  38365. * Sets the current mode used by the behavior
  38366. */
  38367. set mode(mode: number);
  38368. /**
  38369. * Gets current mode used by the behavior.
  38370. */
  38371. get mode(): number;
  38372. /**
  38373. * Sets the scale applied to the radius (1 by default)
  38374. */
  38375. set radiusScale(radius: number);
  38376. /**
  38377. * Gets the scale applied to the radius
  38378. */
  38379. get radiusScale(): number;
  38380. /**
  38381. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38382. */
  38383. set positionScale(scale: number);
  38384. /**
  38385. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38386. */
  38387. get positionScale(): number;
  38388. /**
  38389. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38390. * behaviour is triggered, in radians.
  38391. */
  38392. set defaultElevation(elevation: number);
  38393. /**
  38394. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38395. * behaviour is triggered, in radians.
  38396. */
  38397. get defaultElevation(): number;
  38398. /**
  38399. * Sets the time (in milliseconds) taken to return to the default beta position.
  38400. * Negative value indicates camera should not return to default.
  38401. */
  38402. set elevationReturnTime(speed: number);
  38403. /**
  38404. * Gets the time (in milliseconds) taken to return to the default beta position.
  38405. * Negative value indicates camera should not return to default.
  38406. */
  38407. get elevationReturnTime(): number;
  38408. /**
  38409. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38410. */
  38411. set elevationReturnWaitTime(time: number);
  38412. /**
  38413. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38414. */
  38415. get elevationReturnWaitTime(): number;
  38416. /**
  38417. * Sets the flag that indicates if user zooming should stop animation.
  38418. */
  38419. set zoomStopsAnimation(flag: boolean);
  38420. /**
  38421. * Gets the flag that indicates if user zooming should stop animation.
  38422. */
  38423. get zoomStopsAnimation(): boolean;
  38424. /**
  38425. * Sets the transition time when framing the mesh, in milliseconds
  38426. */
  38427. set framingTime(time: number);
  38428. /**
  38429. * Gets the transition time when framing the mesh, in milliseconds
  38430. */
  38431. get framingTime(): number;
  38432. /**
  38433. * Define if the behavior should automatically change the configured
  38434. * camera limits and sensibilities.
  38435. */
  38436. autoCorrectCameraLimitsAndSensibility: boolean;
  38437. private _onPrePointerObservableObserver;
  38438. private _onAfterCheckInputsObserver;
  38439. private _onMeshTargetChangedObserver;
  38440. private _attachedCamera;
  38441. private _isPointerDown;
  38442. private _lastInteractionTime;
  38443. /**
  38444. * Initializes the behavior.
  38445. */
  38446. init(): void;
  38447. /**
  38448. * Attaches the behavior to its arc rotate camera.
  38449. * @param camera Defines the camera to attach the behavior to
  38450. */
  38451. attach(camera: ArcRotateCamera): void;
  38452. /**
  38453. * Detaches the behavior from its current arc rotate camera.
  38454. */
  38455. detach(): void;
  38456. private _animatables;
  38457. private _betaIsAnimating;
  38458. private _betaTransition;
  38459. private _radiusTransition;
  38460. private _vectorTransition;
  38461. /**
  38462. * Targets the given mesh and updates zoom level accordingly.
  38463. * @param mesh The mesh to target.
  38464. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38465. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38466. */
  38467. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38468. /**
  38469. * Targets the given mesh with its children and updates zoom level accordingly.
  38470. * @param mesh The mesh to target.
  38471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38473. */
  38474. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38475. /**
  38476. * Targets the given meshes with their children and updates zoom level accordingly.
  38477. * @param meshes The mesh to target.
  38478. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38479. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38480. */
  38481. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38482. /**
  38483. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38484. * @param minimumWorld Determines the smaller position of the bounding box extend
  38485. * @param maximumWorld Determines the bigger position of the bounding box extend
  38486. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38487. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38488. */
  38489. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38490. /**
  38491. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38492. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38493. * frustum width.
  38494. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38495. * to fully enclose the mesh in the viewing frustum.
  38496. */
  38497. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38498. /**
  38499. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38500. * is automatically returned to its default position (expected to be above ground plane).
  38501. */
  38502. private _maintainCameraAboveGround;
  38503. /**
  38504. * Returns the frustum slope based on the canvas ratio and camera FOV
  38505. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38506. */
  38507. private _getFrustumSlope;
  38508. /**
  38509. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38510. */
  38511. private _clearAnimationLocks;
  38512. /**
  38513. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38514. */
  38515. private _applyUserInteraction;
  38516. /**
  38517. * Stops and removes all animations that have been applied to the camera
  38518. */
  38519. stopAllAnimations(): void;
  38520. /**
  38521. * Gets a value indicating if the user is moving the camera
  38522. */
  38523. get isUserIsMoving(): boolean;
  38524. /**
  38525. * The camera can move all the way towards the mesh.
  38526. */
  38527. static IgnoreBoundsSizeMode: number;
  38528. /**
  38529. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38530. */
  38531. static FitFrustumSidesMode: number;
  38532. }
  38533. }
  38534. declare module BABYLON {
  38535. /**
  38536. * Base class for Camera Pointer Inputs.
  38537. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38538. * for example usage.
  38539. */
  38540. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38541. /**
  38542. * Defines the camera the input is attached to.
  38543. */
  38544. abstract camera: Camera;
  38545. /**
  38546. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38547. */
  38548. protected _altKey: boolean;
  38549. protected _ctrlKey: boolean;
  38550. protected _metaKey: boolean;
  38551. protected _shiftKey: boolean;
  38552. /**
  38553. * Which mouse buttons were pressed at time of last mouse event.
  38554. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38555. */
  38556. protected _buttonsPressed: number;
  38557. /**
  38558. * Defines the buttons associated with the input to handle camera move.
  38559. */
  38560. buttons: number[];
  38561. /**
  38562. * Attach the input controls to a specific dom element to get the input from.
  38563. * @param element Defines the element the controls should be listened from
  38564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38565. */
  38566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38567. /**
  38568. * Detach the current controls from the specified dom element.
  38569. * @param element Defines the element to stop listening the inputs from
  38570. */
  38571. detachControl(element: Nullable<HTMLElement>): void;
  38572. /**
  38573. * Gets the class name of the current input.
  38574. * @returns the class name
  38575. */
  38576. getClassName(): string;
  38577. /**
  38578. * Get the friendly name associated with the input class.
  38579. * @returns the input friendly name
  38580. */
  38581. getSimpleName(): string;
  38582. /**
  38583. * Called on pointer POINTERDOUBLETAP event.
  38584. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38585. */
  38586. protected onDoubleTap(type: string): void;
  38587. /**
  38588. * Called on pointer POINTERMOVE event if only a single touch is active.
  38589. * Override this method to provide functionality.
  38590. */
  38591. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38592. /**
  38593. * Called on pointer POINTERMOVE event if multiple touches are active.
  38594. * Override this method to provide functionality.
  38595. */
  38596. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38597. /**
  38598. * Called on JS contextmenu event.
  38599. * Override this method to provide functionality.
  38600. */
  38601. protected onContextMenu(evt: PointerEvent): void;
  38602. /**
  38603. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38604. * press.
  38605. * Override this method to provide functionality.
  38606. */
  38607. protected onButtonDown(evt: PointerEvent): void;
  38608. /**
  38609. * Called each time a new POINTERUP event occurs. Ie, for each button
  38610. * release.
  38611. * Override this method to provide functionality.
  38612. */
  38613. protected onButtonUp(evt: PointerEvent): void;
  38614. /**
  38615. * Called when window becomes inactive.
  38616. * Override this method to provide functionality.
  38617. */
  38618. protected onLostFocus(): void;
  38619. private _pointerInput;
  38620. private _observer;
  38621. private _onLostFocus;
  38622. private pointA;
  38623. private pointB;
  38624. }
  38625. }
  38626. declare module BABYLON {
  38627. /**
  38628. * Manage the pointers inputs to control an arc rotate camera.
  38629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38630. */
  38631. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38632. /**
  38633. * Defines the camera the input is attached to.
  38634. */
  38635. camera: ArcRotateCamera;
  38636. /**
  38637. * Gets the class name of the current input.
  38638. * @returns the class name
  38639. */
  38640. getClassName(): string;
  38641. /**
  38642. * Defines the buttons associated with the input to handle camera move.
  38643. */
  38644. buttons: number[];
  38645. /**
  38646. * Defines the pointer angular sensibility along the X axis or how fast is
  38647. * the camera rotating.
  38648. */
  38649. angularSensibilityX: number;
  38650. /**
  38651. * Defines the pointer angular sensibility along the Y axis or how fast is
  38652. * the camera rotating.
  38653. */
  38654. angularSensibilityY: number;
  38655. /**
  38656. * Defines the pointer pinch precision or how fast is the camera zooming.
  38657. */
  38658. pinchPrecision: number;
  38659. /**
  38660. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38661. * from 0.
  38662. * It defines the percentage of current camera.radius to use as delta when
  38663. * pinch zoom is used.
  38664. */
  38665. pinchDeltaPercentage: number;
  38666. /**
  38667. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38668. * that any object in the plane at the camera's target point will scale
  38669. * perfectly with finger motion.
  38670. * Overrides pinchDeltaPercentage and pinchPrecision.
  38671. */
  38672. useNaturalPinchZoom: boolean;
  38673. /**
  38674. * Defines the pointer panning sensibility or how fast is the camera moving.
  38675. */
  38676. panningSensibility: number;
  38677. /**
  38678. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38679. */
  38680. multiTouchPanning: boolean;
  38681. /**
  38682. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38683. * zoom (pinch) through multitouch.
  38684. */
  38685. multiTouchPanAndZoom: boolean;
  38686. /**
  38687. * Revers pinch action direction.
  38688. */
  38689. pinchInwards: boolean;
  38690. private _isPanClick;
  38691. private _twoFingerActivityCount;
  38692. private _isPinching;
  38693. /**
  38694. * Called on pointer POINTERMOVE event if only a single touch is active.
  38695. */
  38696. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38697. /**
  38698. * Called on pointer POINTERDOUBLETAP event.
  38699. */
  38700. protected onDoubleTap(type: string): void;
  38701. /**
  38702. * Called on pointer POINTERMOVE event if multiple touches are active.
  38703. */
  38704. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38705. /**
  38706. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38707. * press.
  38708. */
  38709. protected onButtonDown(evt: PointerEvent): void;
  38710. /**
  38711. * Called each time a new POINTERUP event occurs. Ie, for each button
  38712. * release.
  38713. */
  38714. protected onButtonUp(evt: PointerEvent): void;
  38715. /**
  38716. * Called when window becomes inactive.
  38717. */
  38718. protected onLostFocus(): void;
  38719. }
  38720. }
  38721. declare module BABYLON {
  38722. /**
  38723. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38725. */
  38726. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38727. /**
  38728. * Defines the camera the input is attached to.
  38729. */
  38730. camera: ArcRotateCamera;
  38731. /**
  38732. * Defines the list of key codes associated with the up action (increase alpha)
  38733. */
  38734. keysUp: number[];
  38735. /**
  38736. * Defines the list of key codes associated with the down action (decrease alpha)
  38737. */
  38738. keysDown: number[];
  38739. /**
  38740. * Defines the list of key codes associated with the left action (increase beta)
  38741. */
  38742. keysLeft: number[];
  38743. /**
  38744. * Defines the list of key codes associated with the right action (decrease beta)
  38745. */
  38746. keysRight: number[];
  38747. /**
  38748. * Defines the list of key codes associated with the reset action.
  38749. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38750. */
  38751. keysReset: number[];
  38752. /**
  38753. * Defines the panning sensibility of the inputs.
  38754. * (How fast is the camera panning)
  38755. */
  38756. panningSensibility: number;
  38757. /**
  38758. * Defines the zooming sensibility of the inputs.
  38759. * (How fast is the camera zooming)
  38760. */
  38761. zoomingSensibility: number;
  38762. /**
  38763. * Defines whether maintaining the alt key down switch the movement mode from
  38764. * orientation to zoom.
  38765. */
  38766. useAltToZoom: boolean;
  38767. /**
  38768. * Rotation speed of the camera
  38769. */
  38770. angularSpeed: number;
  38771. private _keys;
  38772. private _ctrlPressed;
  38773. private _altPressed;
  38774. private _onCanvasBlurObserver;
  38775. private _onKeyboardObserver;
  38776. private _engine;
  38777. private _scene;
  38778. /**
  38779. * Attach the input controls to a specific dom element to get the input from.
  38780. * @param element Defines the element the controls should be listened from
  38781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38782. */
  38783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38784. /**
  38785. * Detach the current controls from the specified dom element.
  38786. * @param element Defines the element to stop listening the inputs from
  38787. */
  38788. detachControl(element: Nullable<HTMLElement>): void;
  38789. /**
  38790. * Update the current camera state depending on the inputs that have been used this frame.
  38791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38792. */
  38793. checkInputs(): void;
  38794. /**
  38795. * Gets the class name of the current intput.
  38796. * @returns the class name
  38797. */
  38798. getClassName(): string;
  38799. /**
  38800. * Get the friendly name associated with the input class.
  38801. * @returns the input friendly name
  38802. */
  38803. getSimpleName(): string;
  38804. }
  38805. }
  38806. declare module BABYLON {
  38807. /**
  38808. * Manage the mouse wheel inputs to control an arc rotate camera.
  38809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38810. */
  38811. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38812. /**
  38813. * Defines the camera the input is attached to.
  38814. */
  38815. camera: ArcRotateCamera;
  38816. /**
  38817. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38818. */
  38819. wheelPrecision: number;
  38820. /**
  38821. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38822. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38823. */
  38824. wheelDeltaPercentage: number;
  38825. private _wheel;
  38826. private _observer;
  38827. private computeDeltaFromMouseWheelLegacyEvent;
  38828. /**
  38829. * Attach the input controls to a specific dom element to get the input from.
  38830. * @param element Defines the element the controls should be listened from
  38831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38832. */
  38833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38834. /**
  38835. * Detach the current controls from the specified dom element.
  38836. * @param element Defines the element to stop listening the inputs from
  38837. */
  38838. detachControl(element: Nullable<HTMLElement>): void;
  38839. /**
  38840. * Gets the class name of the current intput.
  38841. * @returns the class name
  38842. */
  38843. getClassName(): string;
  38844. /**
  38845. * Get the friendly name associated with the input class.
  38846. * @returns the input friendly name
  38847. */
  38848. getSimpleName(): string;
  38849. }
  38850. }
  38851. declare module BABYLON {
  38852. /**
  38853. * Default Inputs manager for the ArcRotateCamera.
  38854. * It groups all the default supported inputs for ease of use.
  38855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38856. */
  38857. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38858. /**
  38859. * Instantiates a new ArcRotateCameraInputsManager.
  38860. * @param camera Defines the camera the inputs belong to
  38861. */
  38862. constructor(camera: ArcRotateCamera);
  38863. /**
  38864. * Add mouse wheel input support to the input manager.
  38865. * @returns the current input manager
  38866. */
  38867. addMouseWheel(): ArcRotateCameraInputsManager;
  38868. /**
  38869. * Add pointers input support to the input manager.
  38870. * @returns the current input manager
  38871. */
  38872. addPointers(): ArcRotateCameraInputsManager;
  38873. /**
  38874. * Add keyboard input support to the input manager.
  38875. * @returns the current input manager
  38876. */
  38877. addKeyboard(): ArcRotateCameraInputsManager;
  38878. }
  38879. }
  38880. declare module BABYLON {
  38881. /**
  38882. * This represents an orbital type of camera.
  38883. *
  38884. * 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.
  38885. * 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.
  38886. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38887. */
  38888. export class ArcRotateCamera extends TargetCamera {
  38889. /**
  38890. * Defines the rotation angle of the camera along the longitudinal axis.
  38891. */
  38892. alpha: number;
  38893. /**
  38894. * Defines the rotation angle of the camera along the latitudinal axis.
  38895. */
  38896. beta: number;
  38897. /**
  38898. * Defines the radius of the camera from it s target point.
  38899. */
  38900. radius: number;
  38901. protected _target: Vector3;
  38902. protected _targetHost: Nullable<AbstractMesh>;
  38903. /**
  38904. * Defines the target point of the camera.
  38905. * The camera looks towards it form the radius distance.
  38906. */
  38907. get target(): Vector3;
  38908. set target(value: Vector3);
  38909. /**
  38910. * Define the current local position of the camera in the scene
  38911. */
  38912. get position(): Vector3;
  38913. set position(newPosition: Vector3);
  38914. protected _upVector: Vector3;
  38915. protected _upToYMatrix: Matrix;
  38916. protected _YToUpMatrix: Matrix;
  38917. /**
  38918. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38919. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38920. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38921. */
  38922. set upVector(vec: Vector3);
  38923. get upVector(): Vector3;
  38924. /**
  38925. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38926. */
  38927. setMatUp(): void;
  38928. /**
  38929. * Current inertia value on the longitudinal axis.
  38930. * The bigger this number the longer it will take for the camera to stop.
  38931. */
  38932. inertialAlphaOffset: number;
  38933. /**
  38934. * Current inertia value on the latitudinal axis.
  38935. * The bigger this number the longer it will take for the camera to stop.
  38936. */
  38937. inertialBetaOffset: number;
  38938. /**
  38939. * Current inertia value on the radius axis.
  38940. * The bigger this number the longer it will take for the camera to stop.
  38941. */
  38942. inertialRadiusOffset: number;
  38943. /**
  38944. * Minimum allowed angle on the longitudinal axis.
  38945. * This can help limiting how the Camera is able to move in the scene.
  38946. */
  38947. lowerAlphaLimit: Nullable<number>;
  38948. /**
  38949. * Maximum allowed angle on the longitudinal axis.
  38950. * This can help limiting how the Camera is able to move in the scene.
  38951. */
  38952. upperAlphaLimit: Nullable<number>;
  38953. /**
  38954. * Minimum allowed angle on the latitudinal axis.
  38955. * This can help limiting how the Camera is able to move in the scene.
  38956. */
  38957. lowerBetaLimit: number;
  38958. /**
  38959. * Maximum allowed angle on the latitudinal axis.
  38960. * This can help limiting how the Camera is able to move in the scene.
  38961. */
  38962. upperBetaLimit: number;
  38963. /**
  38964. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38965. * This can help limiting how the Camera is able to move in the scene.
  38966. */
  38967. lowerRadiusLimit: Nullable<number>;
  38968. /**
  38969. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38970. * This can help limiting how the Camera is able to move in the scene.
  38971. */
  38972. upperRadiusLimit: Nullable<number>;
  38973. /**
  38974. * Defines the current inertia value used during panning of the camera along the X axis.
  38975. */
  38976. inertialPanningX: number;
  38977. /**
  38978. * Defines the current inertia value used during panning of the camera along the Y axis.
  38979. */
  38980. inertialPanningY: number;
  38981. /**
  38982. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38983. * Basically if your fingers moves away from more than this distance you will be considered
  38984. * in pinch mode.
  38985. */
  38986. pinchToPanMaxDistance: number;
  38987. /**
  38988. * Defines the maximum distance the camera can pan.
  38989. * This could help keeping the cammera always in your scene.
  38990. */
  38991. panningDistanceLimit: Nullable<number>;
  38992. /**
  38993. * Defines the target of the camera before paning.
  38994. */
  38995. panningOriginTarget: Vector3;
  38996. /**
  38997. * Defines the value of the inertia used during panning.
  38998. * 0 would mean stop inertia and one would mean no decelleration at all.
  38999. */
  39000. panningInertia: number;
  39001. /**
  39002. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39003. */
  39004. get angularSensibilityX(): number;
  39005. set angularSensibilityX(value: number);
  39006. /**
  39007. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39008. */
  39009. get angularSensibilityY(): number;
  39010. set angularSensibilityY(value: number);
  39011. /**
  39012. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39013. */
  39014. get pinchPrecision(): number;
  39015. set pinchPrecision(value: number);
  39016. /**
  39017. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39018. * It will be used instead of pinchDeltaPrecision if different from 0.
  39019. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39020. */
  39021. get pinchDeltaPercentage(): number;
  39022. set pinchDeltaPercentage(value: number);
  39023. /**
  39024. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39025. * and pinch delta percentage.
  39026. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39027. * that any object in the plane at the camera's target point will scale
  39028. * perfectly with finger motion.
  39029. */
  39030. get useNaturalPinchZoom(): boolean;
  39031. set useNaturalPinchZoom(value: boolean);
  39032. /**
  39033. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39034. */
  39035. get panningSensibility(): number;
  39036. set panningSensibility(value: number);
  39037. /**
  39038. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39039. */
  39040. get keysUp(): number[];
  39041. set keysUp(value: number[]);
  39042. /**
  39043. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39044. */
  39045. get keysDown(): number[];
  39046. set keysDown(value: number[]);
  39047. /**
  39048. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39049. */
  39050. get keysLeft(): number[];
  39051. set keysLeft(value: number[]);
  39052. /**
  39053. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39054. */
  39055. get keysRight(): number[];
  39056. set keysRight(value: number[]);
  39057. /**
  39058. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39059. */
  39060. get wheelPrecision(): number;
  39061. set wheelPrecision(value: number);
  39062. /**
  39063. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39064. * It will be used instead of pinchDeltaPrecision if different from 0.
  39065. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39066. */
  39067. get wheelDeltaPercentage(): number;
  39068. set wheelDeltaPercentage(value: number);
  39069. /**
  39070. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39071. */
  39072. zoomOnFactor: number;
  39073. /**
  39074. * Defines a screen offset for the camera position.
  39075. */
  39076. targetScreenOffset: Vector2;
  39077. /**
  39078. * Allows the camera to be completely reversed.
  39079. * If false the camera can not arrive upside down.
  39080. */
  39081. allowUpsideDown: boolean;
  39082. /**
  39083. * Define if double tap/click is used to restore the previously saved state of the camera.
  39084. */
  39085. useInputToRestoreState: boolean;
  39086. /** @hidden */
  39087. _viewMatrix: Matrix;
  39088. /** @hidden */
  39089. _useCtrlForPanning: boolean;
  39090. /** @hidden */
  39091. _panningMouseButton: number;
  39092. /**
  39093. * Defines the input associated to the camera.
  39094. */
  39095. inputs: ArcRotateCameraInputsManager;
  39096. /** @hidden */
  39097. _reset: () => void;
  39098. /**
  39099. * Defines the allowed panning axis.
  39100. */
  39101. panningAxis: Vector3;
  39102. protected _localDirection: Vector3;
  39103. protected _transformedDirection: Vector3;
  39104. private _bouncingBehavior;
  39105. /**
  39106. * Gets the bouncing behavior of the camera if it has been enabled.
  39107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39108. */
  39109. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39110. /**
  39111. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39113. */
  39114. get useBouncingBehavior(): boolean;
  39115. set useBouncingBehavior(value: boolean);
  39116. private _framingBehavior;
  39117. /**
  39118. * Gets the framing behavior of the camera if it has been enabled.
  39119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39120. */
  39121. get framingBehavior(): Nullable<FramingBehavior>;
  39122. /**
  39123. * Defines if the framing behavior of the camera is enabled on the camera.
  39124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39125. */
  39126. get useFramingBehavior(): boolean;
  39127. set useFramingBehavior(value: boolean);
  39128. private _autoRotationBehavior;
  39129. /**
  39130. * Gets the auto rotation behavior of the camera if it has been enabled.
  39131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39132. */
  39133. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39134. /**
  39135. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39137. */
  39138. get useAutoRotationBehavior(): boolean;
  39139. set useAutoRotationBehavior(value: boolean);
  39140. /**
  39141. * Observable triggered when the mesh target has been changed on the camera.
  39142. */
  39143. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39144. /**
  39145. * Event raised when the camera is colliding with a mesh.
  39146. */
  39147. onCollide: (collidedMesh: AbstractMesh) => void;
  39148. /**
  39149. * Defines whether the camera should check collision with the objects oh the scene.
  39150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39151. */
  39152. checkCollisions: boolean;
  39153. /**
  39154. * Defines the collision radius of the camera.
  39155. * This simulates a sphere around the camera.
  39156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39157. */
  39158. collisionRadius: Vector3;
  39159. protected _collider: Collider;
  39160. protected _previousPosition: Vector3;
  39161. protected _collisionVelocity: Vector3;
  39162. protected _newPosition: Vector3;
  39163. protected _previousAlpha: number;
  39164. protected _previousBeta: number;
  39165. protected _previousRadius: number;
  39166. protected _collisionTriggered: boolean;
  39167. protected _targetBoundingCenter: Nullable<Vector3>;
  39168. private _computationVector;
  39169. /**
  39170. * Instantiates a new ArcRotateCamera in a given scene
  39171. * @param name Defines the name of the camera
  39172. * @param alpha Defines the camera rotation along the logitudinal axis
  39173. * @param beta Defines the camera rotation along the latitudinal axis
  39174. * @param radius Defines the camera distance from its target
  39175. * @param target Defines the camera target
  39176. * @param scene Defines the scene the camera belongs to
  39177. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39178. */
  39179. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39180. /** @hidden */
  39181. _initCache(): void;
  39182. /** @hidden */
  39183. _updateCache(ignoreParentClass?: boolean): void;
  39184. protected _getTargetPosition(): Vector3;
  39185. private _storedAlpha;
  39186. private _storedBeta;
  39187. private _storedRadius;
  39188. private _storedTarget;
  39189. private _storedTargetScreenOffset;
  39190. /**
  39191. * Stores the current state of the camera (alpha, beta, radius and target)
  39192. * @returns the camera itself
  39193. */
  39194. storeState(): Camera;
  39195. /**
  39196. * @hidden
  39197. * Restored camera state. You must call storeState() first
  39198. */
  39199. _restoreStateValues(): boolean;
  39200. /** @hidden */
  39201. _isSynchronizedViewMatrix(): boolean;
  39202. /**
  39203. * Attached controls to the current camera.
  39204. * @param element Defines the element the controls should be listened from
  39205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39206. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39207. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39208. */
  39209. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39210. /**
  39211. * Detach the current controls from the camera.
  39212. * The camera will stop reacting to inputs.
  39213. * @param element Defines the element to stop listening the inputs from
  39214. */
  39215. detachControl(element: HTMLElement): void;
  39216. /** @hidden */
  39217. _checkInputs(): void;
  39218. protected _checkLimits(): void;
  39219. /**
  39220. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39221. */
  39222. rebuildAnglesAndRadius(): void;
  39223. /**
  39224. * Use a position to define the current camera related information like alpha, beta and radius
  39225. * @param position Defines the position to set the camera at
  39226. */
  39227. setPosition(position: Vector3): void;
  39228. /**
  39229. * Defines the target the camera should look at.
  39230. * This will automatically adapt alpha beta and radius to fit within the new target.
  39231. * @param target Defines the new target as a Vector or a mesh
  39232. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39233. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39234. */
  39235. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39236. /** @hidden */
  39237. _getViewMatrix(): Matrix;
  39238. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39239. /**
  39240. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39241. * @param meshes Defines the mesh to zoom on
  39242. * @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)
  39243. */
  39244. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39245. /**
  39246. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39247. * The target will be changed but the radius
  39248. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39249. * @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)
  39250. */
  39251. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39252. min: Vector3;
  39253. max: Vector3;
  39254. distance: number;
  39255. }, doNotUpdateMaxZ?: boolean): void;
  39256. /**
  39257. * @override
  39258. * Override Camera.createRigCamera
  39259. */
  39260. createRigCamera(name: string, cameraIndex: number): Camera;
  39261. /**
  39262. * @hidden
  39263. * @override
  39264. * Override Camera._updateRigCameras
  39265. */
  39266. _updateRigCameras(): void;
  39267. /**
  39268. * Destroy the camera and release the current resources hold by it.
  39269. */
  39270. dispose(): void;
  39271. /**
  39272. * Gets the current object class name.
  39273. * @return the class name
  39274. */
  39275. getClassName(): string;
  39276. }
  39277. }
  39278. declare module BABYLON {
  39279. /**
  39280. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39281. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39282. */
  39283. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39284. /**
  39285. * Gets the name of the behavior.
  39286. */
  39287. get name(): string;
  39288. private _zoomStopsAnimation;
  39289. private _idleRotationSpeed;
  39290. private _idleRotationWaitTime;
  39291. private _idleRotationSpinupTime;
  39292. /**
  39293. * Sets the flag that indicates if user zooming should stop animation.
  39294. */
  39295. set zoomStopsAnimation(flag: boolean);
  39296. /**
  39297. * Gets the flag that indicates if user zooming should stop animation.
  39298. */
  39299. get zoomStopsAnimation(): boolean;
  39300. /**
  39301. * Sets the default speed at which the camera rotates around the model.
  39302. */
  39303. set idleRotationSpeed(speed: number);
  39304. /**
  39305. * Gets the default speed at which the camera rotates around the model.
  39306. */
  39307. get idleRotationSpeed(): number;
  39308. /**
  39309. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39310. */
  39311. set idleRotationWaitTime(time: number);
  39312. /**
  39313. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39314. */
  39315. get idleRotationWaitTime(): number;
  39316. /**
  39317. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39318. */
  39319. set idleRotationSpinupTime(time: number);
  39320. /**
  39321. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39322. */
  39323. get idleRotationSpinupTime(): number;
  39324. /**
  39325. * Gets a value indicating if the camera is currently rotating because of this behavior
  39326. */
  39327. get rotationInProgress(): boolean;
  39328. private _onPrePointerObservableObserver;
  39329. private _onAfterCheckInputsObserver;
  39330. private _attachedCamera;
  39331. private _isPointerDown;
  39332. private _lastFrameTime;
  39333. private _lastInteractionTime;
  39334. private _cameraRotationSpeed;
  39335. /**
  39336. * Initializes the behavior.
  39337. */
  39338. init(): void;
  39339. /**
  39340. * Attaches the behavior to its arc rotate camera.
  39341. * @param camera Defines the camera to attach the behavior to
  39342. */
  39343. attach(camera: ArcRotateCamera): void;
  39344. /**
  39345. * Detaches the behavior from its current arc rotate camera.
  39346. */
  39347. detach(): void;
  39348. /**
  39349. * Returns true if user is scrolling.
  39350. * @return true if user is scrolling.
  39351. */
  39352. private _userIsZooming;
  39353. private _lastFrameRadius;
  39354. private _shouldAnimationStopForInteraction;
  39355. /**
  39356. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39357. */
  39358. private _applyUserInteraction;
  39359. private _userIsMoving;
  39360. }
  39361. }
  39362. declare module BABYLON {
  39363. /**
  39364. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39365. */
  39366. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39367. private ui;
  39368. /**
  39369. * The name of the behavior
  39370. */
  39371. name: string;
  39372. /**
  39373. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39374. */
  39375. distanceAwayFromFace: number;
  39376. /**
  39377. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39378. */
  39379. distanceAwayFromBottomOfFace: number;
  39380. private _faceVectors;
  39381. private _target;
  39382. private _scene;
  39383. private _onRenderObserver;
  39384. private _tmpMatrix;
  39385. private _tmpVector;
  39386. /**
  39387. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39388. * @param ui The transform node that should be attched to the mesh
  39389. */
  39390. constructor(ui: TransformNode);
  39391. /**
  39392. * Initializes the behavior
  39393. */
  39394. init(): void;
  39395. private _closestFace;
  39396. private _zeroVector;
  39397. private _lookAtTmpMatrix;
  39398. private _lookAtToRef;
  39399. /**
  39400. * Attaches the AttachToBoxBehavior to the passed in mesh
  39401. * @param target The mesh that the specified node will be attached to
  39402. */
  39403. attach(target: Mesh): void;
  39404. /**
  39405. * Detaches the behavior from the mesh
  39406. */
  39407. detach(): void;
  39408. }
  39409. }
  39410. declare module BABYLON {
  39411. /**
  39412. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39413. */
  39414. export class FadeInOutBehavior implements Behavior<Mesh> {
  39415. /**
  39416. * Time in milliseconds to delay before fading in (Default: 0)
  39417. */
  39418. delay: number;
  39419. /**
  39420. * Time in milliseconds for the mesh to fade in (Default: 300)
  39421. */
  39422. fadeInTime: number;
  39423. private _millisecondsPerFrame;
  39424. private _hovered;
  39425. private _hoverValue;
  39426. private _ownerNode;
  39427. /**
  39428. * Instatiates the FadeInOutBehavior
  39429. */
  39430. constructor();
  39431. /**
  39432. * The name of the behavior
  39433. */
  39434. get name(): string;
  39435. /**
  39436. * Initializes the behavior
  39437. */
  39438. init(): void;
  39439. /**
  39440. * Attaches the fade behavior on the passed in mesh
  39441. * @param ownerNode The mesh that will be faded in/out once attached
  39442. */
  39443. attach(ownerNode: Mesh): void;
  39444. /**
  39445. * Detaches the behavior from the mesh
  39446. */
  39447. detach(): void;
  39448. /**
  39449. * Triggers the mesh to begin fading in or out
  39450. * @param value if the object should fade in or out (true to fade in)
  39451. */
  39452. fadeIn(value: boolean): void;
  39453. private _update;
  39454. private _setAllVisibility;
  39455. }
  39456. }
  39457. declare module BABYLON {
  39458. /**
  39459. * Class containing a set of static utilities functions for managing Pivots
  39460. * @hidden
  39461. */
  39462. export class PivotTools {
  39463. private static _PivotCached;
  39464. private static _OldPivotPoint;
  39465. private static _PivotTranslation;
  39466. private static _PivotTmpVector;
  39467. /** @hidden */
  39468. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39469. /** @hidden */
  39470. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39471. }
  39472. }
  39473. declare module BABYLON {
  39474. /**
  39475. * Class containing static functions to help procedurally build meshes
  39476. */
  39477. export class PlaneBuilder {
  39478. /**
  39479. * Creates a plane mesh
  39480. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39481. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39482. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39484. * * 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
  39485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39486. * @param name defines the name of the mesh
  39487. * @param options defines the options used to create the mesh
  39488. * @param scene defines the hosting scene
  39489. * @returns the plane mesh
  39490. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39491. */
  39492. static CreatePlane(name: string, options: {
  39493. size?: number;
  39494. width?: number;
  39495. height?: number;
  39496. sideOrientation?: number;
  39497. frontUVs?: Vector4;
  39498. backUVs?: Vector4;
  39499. updatable?: boolean;
  39500. sourcePlane?: Plane;
  39501. }, scene?: Nullable<Scene>): Mesh;
  39502. }
  39503. }
  39504. declare module BABYLON {
  39505. /**
  39506. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39507. */
  39508. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39509. private static _AnyMouseID;
  39510. /**
  39511. * Abstract mesh the behavior is set on
  39512. */
  39513. attachedNode: AbstractMesh;
  39514. private _dragPlane;
  39515. private _scene;
  39516. private _pointerObserver;
  39517. private _beforeRenderObserver;
  39518. private static _planeScene;
  39519. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39520. /**
  39521. * 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)
  39522. */
  39523. maxDragAngle: number;
  39524. /**
  39525. * @hidden
  39526. */
  39527. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39528. /**
  39529. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39530. */
  39531. currentDraggingPointerID: number;
  39532. /**
  39533. * The last position where the pointer hit the drag plane in world space
  39534. */
  39535. lastDragPosition: Vector3;
  39536. /**
  39537. * If the behavior is currently in a dragging state
  39538. */
  39539. dragging: boolean;
  39540. /**
  39541. * 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)
  39542. */
  39543. dragDeltaRatio: number;
  39544. /**
  39545. * If the drag plane orientation should be updated during the dragging (Default: true)
  39546. */
  39547. updateDragPlane: boolean;
  39548. private _debugMode;
  39549. private _moving;
  39550. /**
  39551. * Fires each time the attached mesh is dragged with the pointer
  39552. * * delta between last drag position and current drag position in world space
  39553. * * dragDistance along the drag axis
  39554. * * dragPlaneNormal normal of the current drag plane used during the drag
  39555. * * dragPlanePoint in world space where the drag intersects the drag plane
  39556. */
  39557. onDragObservable: Observable<{
  39558. delta: Vector3;
  39559. dragPlanePoint: Vector3;
  39560. dragPlaneNormal: Vector3;
  39561. dragDistance: number;
  39562. pointerId: number;
  39563. }>;
  39564. /**
  39565. * Fires each time a drag begins (eg. mouse down on mesh)
  39566. */
  39567. onDragStartObservable: Observable<{
  39568. dragPlanePoint: Vector3;
  39569. pointerId: number;
  39570. }>;
  39571. /**
  39572. * Fires each time a drag ends (eg. mouse release after drag)
  39573. */
  39574. onDragEndObservable: Observable<{
  39575. dragPlanePoint: Vector3;
  39576. pointerId: number;
  39577. }>;
  39578. /**
  39579. * If the attached mesh should be moved when dragged
  39580. */
  39581. moveAttached: boolean;
  39582. /**
  39583. * If the drag behavior will react to drag events (Default: true)
  39584. */
  39585. enabled: boolean;
  39586. /**
  39587. * If pointer events should start and release the drag (Default: true)
  39588. */
  39589. startAndReleaseDragOnPointerEvents: boolean;
  39590. /**
  39591. * If camera controls should be detached during the drag
  39592. */
  39593. detachCameraControls: boolean;
  39594. /**
  39595. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39596. */
  39597. useObjectOrientationForDragging: boolean;
  39598. private _options;
  39599. /**
  39600. * Gets the options used by the behavior
  39601. */
  39602. get options(): {
  39603. dragAxis?: Vector3;
  39604. dragPlaneNormal?: Vector3;
  39605. };
  39606. /**
  39607. * Sets the options used by the behavior
  39608. */
  39609. set options(options: {
  39610. dragAxis?: Vector3;
  39611. dragPlaneNormal?: Vector3;
  39612. });
  39613. /**
  39614. * Creates a pointer drag behavior that can be attached to a mesh
  39615. * @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)
  39616. */
  39617. constructor(options?: {
  39618. dragAxis?: Vector3;
  39619. dragPlaneNormal?: Vector3;
  39620. });
  39621. /**
  39622. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39623. */
  39624. validateDrag: (targetPosition: Vector3) => boolean;
  39625. /**
  39626. * The name of the behavior
  39627. */
  39628. get name(): string;
  39629. /**
  39630. * Initializes the behavior
  39631. */
  39632. init(): void;
  39633. private _tmpVector;
  39634. private _alternatePickedPoint;
  39635. private _worldDragAxis;
  39636. private _targetPosition;
  39637. private _attachedElement;
  39638. /**
  39639. * Attaches the drag behavior the passed in mesh
  39640. * @param ownerNode The mesh that will be dragged around once attached
  39641. * @param predicate Predicate to use for pick filtering
  39642. */
  39643. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39644. /**
  39645. * Force relase the drag action by code.
  39646. */
  39647. releaseDrag(): void;
  39648. private _startDragRay;
  39649. private _lastPointerRay;
  39650. /**
  39651. * Simulates the start of a pointer drag event on the behavior
  39652. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39653. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39654. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39655. */
  39656. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39657. private _startDrag;
  39658. private _dragDelta;
  39659. private _moveDrag;
  39660. private _pickWithRayOnDragPlane;
  39661. private _pointA;
  39662. private _pointB;
  39663. private _pointC;
  39664. private _lineA;
  39665. private _lineB;
  39666. private _localAxis;
  39667. private _lookAt;
  39668. private _updateDragPlanePosition;
  39669. /**
  39670. * Detaches the behavior from the mesh
  39671. */
  39672. detach(): void;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. /**
  39677. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39678. */
  39679. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39680. private _dragBehaviorA;
  39681. private _dragBehaviorB;
  39682. private _startDistance;
  39683. private _initialScale;
  39684. private _targetScale;
  39685. private _ownerNode;
  39686. private _sceneRenderObserver;
  39687. /**
  39688. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39689. */
  39690. constructor();
  39691. /**
  39692. * The name of the behavior
  39693. */
  39694. get name(): string;
  39695. /**
  39696. * Initializes the behavior
  39697. */
  39698. init(): void;
  39699. private _getCurrentDistance;
  39700. /**
  39701. * Attaches the scale behavior the passed in mesh
  39702. * @param ownerNode The mesh that will be scaled around once attached
  39703. */
  39704. attach(ownerNode: Mesh): void;
  39705. /**
  39706. * Detaches the behavior from the mesh
  39707. */
  39708. detach(): void;
  39709. }
  39710. }
  39711. declare module BABYLON {
  39712. /**
  39713. * 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
  39714. */
  39715. export class SixDofDragBehavior implements Behavior<Mesh> {
  39716. private static _virtualScene;
  39717. private _ownerNode;
  39718. private _sceneRenderObserver;
  39719. private _scene;
  39720. private _targetPosition;
  39721. private _virtualOriginMesh;
  39722. private _virtualDragMesh;
  39723. private _pointerObserver;
  39724. private _moving;
  39725. private _startingOrientation;
  39726. private _attachedElement;
  39727. /**
  39728. * 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)
  39729. */
  39730. private zDragFactor;
  39731. /**
  39732. * If the object should rotate to face the drag origin
  39733. */
  39734. rotateDraggedObject: boolean;
  39735. /**
  39736. * If the behavior is currently in a dragging state
  39737. */
  39738. dragging: boolean;
  39739. /**
  39740. * 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)
  39741. */
  39742. dragDeltaRatio: number;
  39743. /**
  39744. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39745. */
  39746. currentDraggingPointerID: number;
  39747. /**
  39748. * If camera controls should be detached during the drag
  39749. */
  39750. detachCameraControls: boolean;
  39751. /**
  39752. * Fires each time a drag starts
  39753. */
  39754. onDragStartObservable: Observable<{}>;
  39755. /**
  39756. * Fires each time a drag ends (eg. mouse release after drag)
  39757. */
  39758. onDragEndObservable: Observable<{}>;
  39759. /**
  39760. * 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
  39761. */
  39762. constructor();
  39763. /**
  39764. * The name of the behavior
  39765. */
  39766. get name(): string;
  39767. /**
  39768. * Initializes the behavior
  39769. */
  39770. init(): void;
  39771. /**
  39772. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39773. */
  39774. private get _pointerCamera();
  39775. /**
  39776. * Attaches the scale behavior the passed in mesh
  39777. * @param ownerNode The mesh that will be scaled around once attached
  39778. */
  39779. attach(ownerNode: Mesh): void;
  39780. /**
  39781. * Detaches the behavior from the mesh
  39782. */
  39783. detach(): void;
  39784. }
  39785. }
  39786. declare module BABYLON {
  39787. /**
  39788. * Class used to apply inverse kinematics to bones
  39789. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39790. */
  39791. export class BoneIKController {
  39792. private static _tmpVecs;
  39793. private static _tmpQuat;
  39794. private static _tmpMats;
  39795. /**
  39796. * Gets or sets the target mesh
  39797. */
  39798. targetMesh: AbstractMesh;
  39799. /** Gets or sets the mesh used as pole */
  39800. poleTargetMesh: AbstractMesh;
  39801. /**
  39802. * Gets or sets the bone used as pole
  39803. */
  39804. poleTargetBone: Nullable<Bone>;
  39805. /**
  39806. * Gets or sets the target position
  39807. */
  39808. targetPosition: Vector3;
  39809. /**
  39810. * Gets or sets the pole target position
  39811. */
  39812. poleTargetPosition: Vector3;
  39813. /**
  39814. * Gets or sets the pole target local offset
  39815. */
  39816. poleTargetLocalOffset: Vector3;
  39817. /**
  39818. * Gets or sets the pole angle
  39819. */
  39820. poleAngle: number;
  39821. /**
  39822. * Gets or sets the mesh associated with the controller
  39823. */
  39824. mesh: AbstractMesh;
  39825. /**
  39826. * 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)
  39827. */
  39828. slerpAmount: number;
  39829. private _bone1Quat;
  39830. private _bone1Mat;
  39831. private _bone2Ang;
  39832. private _bone1;
  39833. private _bone2;
  39834. private _bone1Length;
  39835. private _bone2Length;
  39836. private _maxAngle;
  39837. private _maxReach;
  39838. private _rightHandedSystem;
  39839. private _bendAxis;
  39840. private _slerping;
  39841. private _adjustRoll;
  39842. /**
  39843. * Gets or sets maximum allowed angle
  39844. */
  39845. get maxAngle(): number;
  39846. set maxAngle(value: number);
  39847. /**
  39848. * Creates a new BoneIKController
  39849. * @param mesh defines the mesh to control
  39850. * @param bone defines the bone to control
  39851. * @param options defines options to set up the controller
  39852. */
  39853. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39854. targetMesh?: AbstractMesh;
  39855. poleTargetMesh?: AbstractMesh;
  39856. poleTargetBone?: Bone;
  39857. poleTargetLocalOffset?: Vector3;
  39858. poleAngle?: number;
  39859. bendAxis?: Vector3;
  39860. maxAngle?: number;
  39861. slerpAmount?: number;
  39862. });
  39863. private _setMaxAngle;
  39864. /**
  39865. * Force the controller to update the bones
  39866. */
  39867. update(): void;
  39868. }
  39869. }
  39870. declare module BABYLON {
  39871. /**
  39872. * Class used to make a bone look toward a point in space
  39873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39874. */
  39875. export class BoneLookController {
  39876. private static _tmpVecs;
  39877. private static _tmpQuat;
  39878. private static _tmpMats;
  39879. /**
  39880. * The target Vector3 that the bone will look at
  39881. */
  39882. target: Vector3;
  39883. /**
  39884. * The mesh that the bone is attached to
  39885. */
  39886. mesh: AbstractMesh;
  39887. /**
  39888. * The bone that will be looking to the target
  39889. */
  39890. bone: Bone;
  39891. /**
  39892. * The up axis of the coordinate system that is used when the bone is rotated
  39893. */
  39894. upAxis: Vector3;
  39895. /**
  39896. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39897. */
  39898. upAxisSpace: Space;
  39899. /**
  39900. * Used to make an adjustment to the yaw of the bone
  39901. */
  39902. adjustYaw: number;
  39903. /**
  39904. * Used to make an adjustment to the pitch of the bone
  39905. */
  39906. adjustPitch: number;
  39907. /**
  39908. * Used to make an adjustment to the roll of the bone
  39909. */
  39910. adjustRoll: number;
  39911. /**
  39912. * 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)
  39913. */
  39914. slerpAmount: number;
  39915. private _minYaw;
  39916. private _maxYaw;
  39917. private _minPitch;
  39918. private _maxPitch;
  39919. private _minYawSin;
  39920. private _minYawCos;
  39921. private _maxYawSin;
  39922. private _maxYawCos;
  39923. private _midYawConstraint;
  39924. private _minPitchTan;
  39925. private _maxPitchTan;
  39926. private _boneQuat;
  39927. private _slerping;
  39928. private _transformYawPitch;
  39929. private _transformYawPitchInv;
  39930. private _firstFrameSkipped;
  39931. private _yawRange;
  39932. private _fowardAxis;
  39933. /**
  39934. * Gets or sets the minimum yaw angle that the bone can look to
  39935. */
  39936. get minYaw(): number;
  39937. set minYaw(value: number);
  39938. /**
  39939. * Gets or sets the maximum yaw angle that the bone can look to
  39940. */
  39941. get maxYaw(): number;
  39942. set maxYaw(value: number);
  39943. /**
  39944. * Gets or sets the minimum pitch angle that the bone can look to
  39945. */
  39946. get minPitch(): number;
  39947. set minPitch(value: number);
  39948. /**
  39949. * Gets or sets the maximum pitch angle that the bone can look to
  39950. */
  39951. get maxPitch(): number;
  39952. set maxPitch(value: number);
  39953. /**
  39954. * Create a BoneLookController
  39955. * @param mesh the mesh that the bone belongs to
  39956. * @param bone the bone that will be looking to the target
  39957. * @param target the target Vector3 to look at
  39958. * @param options optional settings:
  39959. * * maxYaw: the maximum angle the bone will yaw to
  39960. * * minYaw: the minimum angle the bone will yaw to
  39961. * * maxPitch: the maximum angle the bone will pitch to
  39962. * * minPitch: the minimum angle the bone will yaw to
  39963. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39964. * * upAxis: the up axis of the coordinate system
  39965. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39966. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39967. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39968. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39969. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39970. * * adjustRoll: used to make an adjustment to the roll of the bone
  39971. **/
  39972. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39973. maxYaw?: number;
  39974. minYaw?: number;
  39975. maxPitch?: number;
  39976. minPitch?: number;
  39977. slerpAmount?: number;
  39978. upAxis?: Vector3;
  39979. upAxisSpace?: Space;
  39980. yawAxis?: Vector3;
  39981. pitchAxis?: Vector3;
  39982. adjustYaw?: number;
  39983. adjustPitch?: number;
  39984. adjustRoll?: number;
  39985. });
  39986. /**
  39987. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39988. */
  39989. update(): void;
  39990. private _getAngleDiff;
  39991. private _getAngleBetween;
  39992. private _isAngleBetween;
  39993. }
  39994. }
  39995. declare module BABYLON {
  39996. /**
  39997. * Manage the gamepad inputs to control an arc rotate camera.
  39998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39999. */
  40000. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40001. /**
  40002. * Defines the camera the input is attached to.
  40003. */
  40004. camera: ArcRotateCamera;
  40005. /**
  40006. * Defines the gamepad the input is gathering event from.
  40007. */
  40008. gamepad: Nullable<Gamepad>;
  40009. /**
  40010. * Defines the gamepad rotation sensiblity.
  40011. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40012. */
  40013. gamepadRotationSensibility: number;
  40014. /**
  40015. * Defines the gamepad move sensiblity.
  40016. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40017. */
  40018. gamepadMoveSensibility: number;
  40019. private _yAxisScale;
  40020. /**
  40021. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40022. */
  40023. get invertYAxis(): boolean;
  40024. set invertYAxis(value: boolean);
  40025. private _onGamepadConnectedObserver;
  40026. private _onGamepadDisconnectedObserver;
  40027. /**
  40028. * Attach the input controls to a specific dom element to get the input from.
  40029. * @param element Defines the element the controls should be listened from
  40030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40031. */
  40032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40033. /**
  40034. * Detach the current controls from the specified dom element.
  40035. * @param element Defines the element to stop listening the inputs from
  40036. */
  40037. detachControl(element: Nullable<HTMLElement>): void;
  40038. /**
  40039. * Update the current camera state depending on the inputs that have been used this frame.
  40040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40041. */
  40042. checkInputs(): void;
  40043. /**
  40044. * Gets the class name of the current intput.
  40045. * @returns the class name
  40046. */
  40047. getClassName(): string;
  40048. /**
  40049. * Get the friendly name associated with the input class.
  40050. * @returns the input friendly name
  40051. */
  40052. getSimpleName(): string;
  40053. }
  40054. }
  40055. declare module BABYLON {
  40056. interface ArcRotateCameraInputsManager {
  40057. /**
  40058. * Add orientation input support to the input manager.
  40059. * @returns the current input manager
  40060. */
  40061. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40062. }
  40063. /**
  40064. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40066. */
  40067. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40068. /**
  40069. * Defines the camera the input is attached to.
  40070. */
  40071. camera: ArcRotateCamera;
  40072. /**
  40073. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40074. */
  40075. alphaCorrection: number;
  40076. /**
  40077. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40078. */
  40079. gammaCorrection: number;
  40080. private _alpha;
  40081. private _gamma;
  40082. private _dirty;
  40083. private _deviceOrientationHandler;
  40084. /**
  40085. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40086. */
  40087. constructor();
  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. /** @hidden */
  40095. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40096. /**
  40097. * Update the current camera state depending on the inputs that have been used this frame.
  40098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40099. */
  40100. checkInputs(): void;
  40101. /**
  40102. * Detach the current controls from the specified dom element.
  40103. * @param element Defines the element to stop listening the inputs from
  40104. */
  40105. detachControl(element: Nullable<HTMLElement>): void;
  40106. /**
  40107. * Gets the class name of the current intput.
  40108. * @returns the class name
  40109. */
  40110. getClassName(): string;
  40111. /**
  40112. * Get the friendly name associated with the input class.
  40113. * @returns the input friendly name
  40114. */
  40115. getSimpleName(): string;
  40116. }
  40117. }
  40118. declare module BABYLON {
  40119. /**
  40120. * Listen to mouse events to control the camera.
  40121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40122. */
  40123. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40124. /**
  40125. * Defines the camera the input is attached to.
  40126. */
  40127. camera: FlyCamera;
  40128. /**
  40129. * Defines if touch is enabled. (Default is true.)
  40130. */
  40131. touchEnabled: boolean;
  40132. /**
  40133. * Defines the buttons associated with the input to handle camera rotation.
  40134. */
  40135. buttons: number[];
  40136. /**
  40137. * Assign buttons for Yaw control.
  40138. */
  40139. buttonsYaw: number[];
  40140. /**
  40141. * Assign buttons for Pitch control.
  40142. */
  40143. buttonsPitch: number[];
  40144. /**
  40145. * Assign buttons for Roll control.
  40146. */
  40147. buttonsRoll: number[];
  40148. /**
  40149. * Detect if any button is being pressed while mouse is moved.
  40150. * -1 = Mouse locked.
  40151. * 0 = Left button.
  40152. * 1 = Middle Button.
  40153. * 2 = Right Button.
  40154. */
  40155. activeButton: number;
  40156. /**
  40157. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40158. * Higher values reduce its sensitivity.
  40159. */
  40160. angularSensibility: number;
  40161. private _mousemoveCallback;
  40162. private _observer;
  40163. private _rollObserver;
  40164. private previousPosition;
  40165. private noPreventDefault;
  40166. private element;
  40167. /**
  40168. * Listen to mouse events to control the camera.
  40169. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40171. */
  40172. constructor(touchEnabled?: boolean);
  40173. /**
  40174. * Attach the mouse control to the HTML DOM element.
  40175. * @param element Defines the element that listens to the input events.
  40176. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40177. */
  40178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40179. /**
  40180. * Detach the current controls from the specified dom element.
  40181. * @param element Defines the element to stop listening the inputs from
  40182. */
  40183. detachControl(element: Nullable<HTMLElement>): void;
  40184. /**
  40185. * Gets the class name of the current input.
  40186. * @returns the class name.
  40187. */
  40188. getClassName(): string;
  40189. /**
  40190. * Get the friendly name associated with the input class.
  40191. * @returns the input's friendly name.
  40192. */
  40193. getSimpleName(): string;
  40194. private _pointerInput;
  40195. private _onMouseMove;
  40196. /**
  40197. * Rotate camera by mouse offset.
  40198. */
  40199. private rotateCamera;
  40200. }
  40201. }
  40202. declare module BABYLON {
  40203. /**
  40204. * Default Inputs manager for the FlyCamera.
  40205. * It groups all the default supported inputs for ease of use.
  40206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40207. */
  40208. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40209. /**
  40210. * Instantiates a new FlyCameraInputsManager.
  40211. * @param camera Defines the camera the inputs belong to.
  40212. */
  40213. constructor(camera: FlyCamera);
  40214. /**
  40215. * Add keyboard input support to the input manager.
  40216. * @returns the new FlyCameraKeyboardMoveInput().
  40217. */
  40218. addKeyboard(): FlyCameraInputsManager;
  40219. /**
  40220. * Add mouse input support to the input manager.
  40221. * @param touchEnabled Enable touch screen support.
  40222. * @returns the new FlyCameraMouseInput().
  40223. */
  40224. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40225. }
  40226. }
  40227. declare module BABYLON {
  40228. /**
  40229. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40230. * such as in a 3D Space Shooter or a Flight Simulator.
  40231. */
  40232. export class FlyCamera extends TargetCamera {
  40233. /**
  40234. * Define the collision ellipsoid of the camera.
  40235. * This is helpful for simulating a camera body, like a player's body.
  40236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40237. */
  40238. ellipsoid: Vector3;
  40239. /**
  40240. * Define an offset for the position of the ellipsoid around the camera.
  40241. * This can be helpful if the camera is attached away from the player's body center,
  40242. * such as at its head.
  40243. */
  40244. ellipsoidOffset: Vector3;
  40245. /**
  40246. * Enable or disable collisions of the camera with the rest of the scene objects.
  40247. */
  40248. checkCollisions: boolean;
  40249. /**
  40250. * Enable or disable gravity on the camera.
  40251. */
  40252. applyGravity: boolean;
  40253. /**
  40254. * Define the current direction the camera is moving to.
  40255. */
  40256. cameraDirection: Vector3;
  40257. /**
  40258. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40259. * This overrides and empties cameraRotation.
  40260. */
  40261. rotationQuaternion: Quaternion;
  40262. /**
  40263. * Track Roll to maintain the wanted Rolling when looking around.
  40264. */
  40265. _trackRoll: number;
  40266. /**
  40267. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40268. */
  40269. rollCorrect: number;
  40270. /**
  40271. * Mimic a banked turn, Rolling the camera when Yawing.
  40272. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40273. */
  40274. bankedTurn: boolean;
  40275. /**
  40276. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40277. */
  40278. bankedTurnLimit: number;
  40279. /**
  40280. * Value of 0 disables the banked Roll.
  40281. * Value of 1 is equal to the Yaw angle in radians.
  40282. */
  40283. bankedTurnMultiplier: number;
  40284. /**
  40285. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40286. */
  40287. inputs: FlyCameraInputsManager;
  40288. /**
  40289. * Gets the input sensibility for mouse input.
  40290. * Higher values reduce sensitivity.
  40291. */
  40292. get angularSensibility(): number;
  40293. /**
  40294. * Sets the input sensibility for a mouse input.
  40295. * Higher values reduce sensitivity.
  40296. */
  40297. set angularSensibility(value: number);
  40298. /**
  40299. * Get the keys for camera movement forward.
  40300. */
  40301. get keysForward(): number[];
  40302. /**
  40303. * Set the keys for camera movement forward.
  40304. */
  40305. set keysForward(value: number[]);
  40306. /**
  40307. * Get the keys for camera movement backward.
  40308. */
  40309. get keysBackward(): number[];
  40310. set keysBackward(value: number[]);
  40311. /**
  40312. * Get the keys for camera movement up.
  40313. */
  40314. get keysUp(): number[];
  40315. /**
  40316. * Set the keys for camera movement up.
  40317. */
  40318. set keysUp(value: number[]);
  40319. /**
  40320. * Get the keys for camera movement down.
  40321. */
  40322. get keysDown(): number[];
  40323. /**
  40324. * Set the keys for camera movement down.
  40325. */
  40326. set keysDown(value: number[]);
  40327. /**
  40328. * Get the keys for camera movement left.
  40329. */
  40330. get keysLeft(): number[];
  40331. /**
  40332. * Set the keys for camera movement left.
  40333. */
  40334. set keysLeft(value: number[]);
  40335. /**
  40336. * Set the keys for camera movement right.
  40337. */
  40338. get keysRight(): number[];
  40339. /**
  40340. * Set the keys for camera movement right.
  40341. */
  40342. set keysRight(value: number[]);
  40343. /**
  40344. * Event raised when the camera collides with a mesh in the scene.
  40345. */
  40346. onCollide: (collidedMesh: AbstractMesh) => void;
  40347. private _collider;
  40348. private _needMoveForGravity;
  40349. private _oldPosition;
  40350. private _diffPosition;
  40351. private _newPosition;
  40352. /** @hidden */
  40353. _localDirection: Vector3;
  40354. /** @hidden */
  40355. _transformedDirection: Vector3;
  40356. /**
  40357. * Instantiates a FlyCamera.
  40358. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40359. * such as in a 3D Space Shooter or a Flight Simulator.
  40360. * @param name Define the name of the camera in the scene.
  40361. * @param position Define the starting position of the camera in the scene.
  40362. * @param scene Define the scene the camera belongs to.
  40363. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40364. */
  40365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40366. /**
  40367. * Attach a control to the HTML DOM element.
  40368. * @param element Defines the element that listens to the input events.
  40369. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40370. */
  40371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40372. /**
  40373. * Detach a control from the HTML DOM element.
  40374. * The camera will stop reacting to that input.
  40375. * @param element Defines the element that listens to the input events.
  40376. */
  40377. detachControl(element: HTMLElement): void;
  40378. private _collisionMask;
  40379. /**
  40380. * Get the mask that the camera ignores in collision events.
  40381. */
  40382. get collisionMask(): number;
  40383. /**
  40384. * Set the mask that the camera ignores in collision events.
  40385. */
  40386. set collisionMask(mask: number);
  40387. /** @hidden */
  40388. _collideWithWorld(displacement: Vector3): void;
  40389. /** @hidden */
  40390. private _onCollisionPositionChange;
  40391. /** @hidden */
  40392. _checkInputs(): void;
  40393. /** @hidden */
  40394. _decideIfNeedsToMove(): boolean;
  40395. /** @hidden */
  40396. _updatePosition(): void;
  40397. /**
  40398. * Restore the Roll to its target value at the rate specified.
  40399. * @param rate - Higher means slower restoring.
  40400. * @hidden
  40401. */
  40402. restoreRoll(rate: number): void;
  40403. /**
  40404. * Destroy the camera and release the current resources held by it.
  40405. */
  40406. dispose(): void;
  40407. /**
  40408. * Get the current object class name.
  40409. * @returns the class name.
  40410. */
  40411. getClassName(): string;
  40412. }
  40413. }
  40414. declare module BABYLON {
  40415. /**
  40416. * Listen to keyboard events to control the camera.
  40417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40418. */
  40419. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40420. /**
  40421. * Defines the camera the input is attached to.
  40422. */
  40423. camera: FlyCamera;
  40424. /**
  40425. * The list of keyboard keys used to control the forward move of the camera.
  40426. */
  40427. keysForward: number[];
  40428. /**
  40429. * The list of keyboard keys used to control the backward move of the camera.
  40430. */
  40431. keysBackward: number[];
  40432. /**
  40433. * The list of keyboard keys used to control the forward move of the camera.
  40434. */
  40435. keysUp: number[];
  40436. /**
  40437. * The list of keyboard keys used to control the backward move of the camera.
  40438. */
  40439. keysDown: number[];
  40440. /**
  40441. * The list of keyboard keys used to control the right strafe move of the camera.
  40442. */
  40443. keysRight: number[];
  40444. /**
  40445. * The list of keyboard keys used to control the left strafe move of the camera.
  40446. */
  40447. keysLeft: number[];
  40448. private _keys;
  40449. private _onCanvasBlurObserver;
  40450. private _onKeyboardObserver;
  40451. private _engine;
  40452. private _scene;
  40453. /**
  40454. * Attach the input controls to a specific dom element to get the input from.
  40455. * @param element Defines the element the controls should be listened from
  40456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40457. */
  40458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40459. /**
  40460. * Detach the current controls from the specified dom element.
  40461. * @param element Defines the element to stop listening the inputs from
  40462. */
  40463. detachControl(element: Nullable<HTMLElement>): void;
  40464. /**
  40465. * Gets the class name of the current intput.
  40466. * @returns the class name
  40467. */
  40468. getClassName(): string;
  40469. /** @hidden */
  40470. _onLostFocus(e: FocusEvent): void;
  40471. /**
  40472. * Get the friendly name associated with the input class.
  40473. * @returns the input friendly name
  40474. */
  40475. getSimpleName(): string;
  40476. /**
  40477. * Update the current camera state depending on the inputs that have been used this frame.
  40478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40479. */
  40480. checkInputs(): void;
  40481. }
  40482. }
  40483. declare module BABYLON {
  40484. /**
  40485. * Manage the mouse wheel inputs to control a follow camera.
  40486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40487. */
  40488. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40489. /**
  40490. * Defines the camera the input is attached to.
  40491. */
  40492. camera: FollowCamera;
  40493. /**
  40494. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40495. */
  40496. axisControlRadius: boolean;
  40497. /**
  40498. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40499. */
  40500. axisControlHeight: boolean;
  40501. /**
  40502. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40503. */
  40504. axisControlRotation: boolean;
  40505. /**
  40506. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40507. * relation to mouseWheel events.
  40508. */
  40509. wheelPrecision: number;
  40510. /**
  40511. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40512. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40513. */
  40514. wheelDeltaPercentage: number;
  40515. private _wheel;
  40516. private _observer;
  40517. /**
  40518. * Attach the input controls to a specific dom element to get the input from.
  40519. * @param element Defines the element the controls should be listened from
  40520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40521. */
  40522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40523. /**
  40524. * Detach the current controls from the specified dom element.
  40525. * @param element Defines the element to stop listening the inputs from
  40526. */
  40527. detachControl(element: Nullable<HTMLElement>): void;
  40528. /**
  40529. * Gets the class name of the current intput.
  40530. * @returns the class name
  40531. */
  40532. getClassName(): string;
  40533. /**
  40534. * Get the friendly name associated with the input class.
  40535. * @returns the input friendly name
  40536. */
  40537. getSimpleName(): string;
  40538. }
  40539. }
  40540. declare module BABYLON {
  40541. /**
  40542. * Manage the pointers inputs to control an follow camera.
  40543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40544. */
  40545. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40546. /**
  40547. * Defines the camera the input is attached to.
  40548. */
  40549. camera: FollowCamera;
  40550. /**
  40551. * Gets the class name of the current input.
  40552. * @returns the class name
  40553. */
  40554. getClassName(): string;
  40555. /**
  40556. * Defines the pointer angular sensibility along the X axis or how fast is
  40557. * the camera rotating.
  40558. * A negative number will reverse the axis direction.
  40559. */
  40560. angularSensibilityX: number;
  40561. /**
  40562. * Defines the pointer angular sensibility along the Y axis or how fast is
  40563. * the camera rotating.
  40564. * A negative number will reverse the axis direction.
  40565. */
  40566. angularSensibilityY: number;
  40567. /**
  40568. * Defines the pointer pinch precision or how fast is the camera zooming.
  40569. * A negative number will reverse the axis direction.
  40570. */
  40571. pinchPrecision: number;
  40572. /**
  40573. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40574. * from 0.
  40575. * It defines the percentage of current camera.radius to use as delta when
  40576. * pinch zoom is used.
  40577. */
  40578. pinchDeltaPercentage: number;
  40579. /**
  40580. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40581. */
  40582. axisXControlRadius: boolean;
  40583. /**
  40584. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40585. */
  40586. axisXControlHeight: boolean;
  40587. /**
  40588. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40589. */
  40590. axisXControlRotation: boolean;
  40591. /**
  40592. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40593. */
  40594. axisYControlRadius: boolean;
  40595. /**
  40596. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40597. */
  40598. axisYControlHeight: boolean;
  40599. /**
  40600. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40601. */
  40602. axisYControlRotation: boolean;
  40603. /**
  40604. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40605. */
  40606. axisPinchControlRadius: boolean;
  40607. /**
  40608. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40609. */
  40610. axisPinchControlHeight: boolean;
  40611. /**
  40612. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40613. */
  40614. axisPinchControlRotation: boolean;
  40615. /**
  40616. * Log error messages if basic misconfiguration has occurred.
  40617. */
  40618. warningEnable: boolean;
  40619. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40620. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40621. private _warningCounter;
  40622. private _warning;
  40623. }
  40624. }
  40625. declare module BABYLON {
  40626. /**
  40627. * Default Inputs manager for the FollowCamera.
  40628. * It groups all the default supported inputs for ease of use.
  40629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40630. */
  40631. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40632. /**
  40633. * Instantiates a new FollowCameraInputsManager.
  40634. * @param camera Defines the camera the inputs belong to
  40635. */
  40636. constructor(camera: FollowCamera);
  40637. /**
  40638. * Add keyboard input support to the input manager.
  40639. * @returns the current input manager
  40640. */
  40641. addKeyboard(): FollowCameraInputsManager;
  40642. /**
  40643. * Add mouse wheel input support to the input manager.
  40644. * @returns the current input manager
  40645. */
  40646. addMouseWheel(): FollowCameraInputsManager;
  40647. /**
  40648. * Add pointers input support to the input manager.
  40649. * @returns the current input manager
  40650. */
  40651. addPointers(): FollowCameraInputsManager;
  40652. /**
  40653. * Add orientation input support to the input manager.
  40654. * @returns the current input manager
  40655. */
  40656. addVRDeviceOrientation(): FollowCameraInputsManager;
  40657. }
  40658. }
  40659. declare module BABYLON {
  40660. /**
  40661. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40662. * an arc rotate version arcFollowCamera are available.
  40663. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40664. */
  40665. export class FollowCamera extends TargetCamera {
  40666. /**
  40667. * Distance the follow camera should follow an object at
  40668. */
  40669. radius: number;
  40670. /**
  40671. * Minimum allowed distance of the camera to the axis of rotation
  40672. * (The camera can not get closer).
  40673. * This can help limiting how the Camera is able to move in the scene.
  40674. */
  40675. lowerRadiusLimit: Nullable<number>;
  40676. /**
  40677. * Maximum allowed distance of the camera to the axis of rotation
  40678. * (The camera can not get further).
  40679. * This can help limiting how the Camera is able to move in the scene.
  40680. */
  40681. upperRadiusLimit: Nullable<number>;
  40682. /**
  40683. * Define a rotation offset between the camera and the object it follows
  40684. */
  40685. rotationOffset: number;
  40686. /**
  40687. * Minimum allowed angle to camera position relative to target object.
  40688. * This can help limiting how the Camera is able to move in the scene.
  40689. */
  40690. lowerRotationOffsetLimit: Nullable<number>;
  40691. /**
  40692. * Maximum allowed angle to camera position relative to target object.
  40693. * This can help limiting how the Camera is able to move in the scene.
  40694. */
  40695. upperRotationOffsetLimit: Nullable<number>;
  40696. /**
  40697. * Define a height offset between the camera and the object it follows.
  40698. * It can help following an object from the top (like a car chaing a plane)
  40699. */
  40700. heightOffset: number;
  40701. /**
  40702. * Minimum allowed height of camera position relative to target object.
  40703. * This can help limiting how the Camera is able to move in the scene.
  40704. */
  40705. lowerHeightOffsetLimit: Nullable<number>;
  40706. /**
  40707. * Maximum allowed height of camera position relative to target object.
  40708. * This can help limiting how the Camera is able to move in the scene.
  40709. */
  40710. upperHeightOffsetLimit: Nullable<number>;
  40711. /**
  40712. * Define how fast the camera can accelerate to follow it s target.
  40713. */
  40714. cameraAcceleration: number;
  40715. /**
  40716. * Define the speed limit of the camera following an object.
  40717. */
  40718. maxCameraSpeed: number;
  40719. /**
  40720. * Define the target of the camera.
  40721. */
  40722. lockedTarget: Nullable<AbstractMesh>;
  40723. /**
  40724. * Defines the input associated with the camera.
  40725. */
  40726. inputs: FollowCameraInputsManager;
  40727. /**
  40728. * Instantiates the follow camera.
  40729. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40730. * @param name Define the name of the camera in the scene
  40731. * @param position Define the position of the camera
  40732. * @param scene Define the scene the camera belong to
  40733. * @param lockedTarget Define the target of the camera
  40734. */
  40735. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40736. private _follow;
  40737. /**
  40738. * Attached controls to the current camera.
  40739. * @param element Defines the element the controls should be listened from
  40740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40741. */
  40742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40743. /**
  40744. * Detach the current controls from the camera.
  40745. * The camera will stop reacting to inputs.
  40746. * @param element Defines the element to stop listening the inputs from
  40747. */
  40748. detachControl(element: HTMLElement): void;
  40749. /** @hidden */
  40750. _checkInputs(): void;
  40751. private _checkLimits;
  40752. /**
  40753. * Gets the camera class name.
  40754. * @returns the class name
  40755. */
  40756. getClassName(): string;
  40757. }
  40758. /**
  40759. * Arc Rotate version of the follow camera.
  40760. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40761. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40762. */
  40763. export class ArcFollowCamera extends TargetCamera {
  40764. /** The longitudinal angle of the camera */
  40765. alpha: number;
  40766. /** The latitudinal angle of the camera */
  40767. beta: number;
  40768. /** The radius of the camera from its target */
  40769. radius: number;
  40770. /** Define the camera target (the messh it should follow) */
  40771. target: Nullable<AbstractMesh>;
  40772. private _cartesianCoordinates;
  40773. /**
  40774. * Instantiates a new ArcFollowCamera
  40775. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40776. * @param name Define the name of the camera
  40777. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40778. * @param beta Define the rotation angle of the camera around the elevation axis
  40779. * @param radius Define the radius of the camera from its target point
  40780. * @param target Define the target of the camera
  40781. * @param scene Define the scene the camera belongs to
  40782. */
  40783. constructor(name: string,
  40784. /** The longitudinal angle of the camera */
  40785. alpha: number,
  40786. /** The latitudinal angle of the camera */
  40787. beta: number,
  40788. /** The radius of the camera from its target */
  40789. radius: number,
  40790. /** Define the camera target (the messh it should follow) */
  40791. target: Nullable<AbstractMesh>, scene: Scene);
  40792. private _follow;
  40793. /** @hidden */
  40794. _checkInputs(): void;
  40795. /**
  40796. * Returns the class name of the object.
  40797. * It is mostly used internally for serialization purposes.
  40798. */
  40799. getClassName(): string;
  40800. }
  40801. }
  40802. declare module BABYLON {
  40803. /**
  40804. * Manage the keyboard inputs to control the movement of a follow camera.
  40805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40806. */
  40807. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40808. /**
  40809. * Defines the camera the input is attached to.
  40810. */
  40811. camera: FollowCamera;
  40812. /**
  40813. * Defines the list of key codes associated with the up action (increase heightOffset)
  40814. */
  40815. keysHeightOffsetIncr: number[];
  40816. /**
  40817. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40818. */
  40819. keysHeightOffsetDecr: number[];
  40820. /**
  40821. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40822. */
  40823. keysHeightOffsetModifierAlt: boolean;
  40824. /**
  40825. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40826. */
  40827. keysHeightOffsetModifierCtrl: boolean;
  40828. /**
  40829. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40830. */
  40831. keysHeightOffsetModifierShift: boolean;
  40832. /**
  40833. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40834. */
  40835. keysRotationOffsetIncr: number[];
  40836. /**
  40837. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40838. */
  40839. keysRotationOffsetDecr: number[];
  40840. /**
  40841. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40842. */
  40843. keysRotationOffsetModifierAlt: boolean;
  40844. /**
  40845. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40846. */
  40847. keysRotationOffsetModifierCtrl: boolean;
  40848. /**
  40849. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40850. */
  40851. keysRotationOffsetModifierShift: boolean;
  40852. /**
  40853. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40854. */
  40855. keysRadiusIncr: number[];
  40856. /**
  40857. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40858. */
  40859. keysRadiusDecr: number[];
  40860. /**
  40861. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40862. */
  40863. keysRadiusModifierAlt: boolean;
  40864. /**
  40865. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40866. */
  40867. keysRadiusModifierCtrl: boolean;
  40868. /**
  40869. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40870. */
  40871. keysRadiusModifierShift: boolean;
  40872. /**
  40873. * Defines the rate of change of heightOffset.
  40874. */
  40875. heightSensibility: number;
  40876. /**
  40877. * Defines the rate of change of rotationOffset.
  40878. */
  40879. rotationSensibility: number;
  40880. /**
  40881. * Defines the rate of change of radius.
  40882. */
  40883. radiusSensibility: number;
  40884. private _keys;
  40885. private _ctrlPressed;
  40886. private _altPressed;
  40887. private _shiftPressed;
  40888. private _onCanvasBlurObserver;
  40889. private _onKeyboardObserver;
  40890. private _engine;
  40891. private _scene;
  40892. /**
  40893. * Attach the input controls to a specific dom element to get the input from.
  40894. * @param element Defines the element the controls should be listened from
  40895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40896. */
  40897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40898. /**
  40899. * Detach the current controls from the specified dom element.
  40900. * @param element Defines the element to stop listening the inputs from
  40901. */
  40902. detachControl(element: Nullable<HTMLElement>): void;
  40903. /**
  40904. * Update the current camera state depending on the inputs that have been used this frame.
  40905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40906. */
  40907. checkInputs(): void;
  40908. /**
  40909. * Gets the class name of the current input.
  40910. * @returns the class name
  40911. */
  40912. getClassName(): string;
  40913. /**
  40914. * Get the friendly name associated with the input class.
  40915. * @returns the input friendly name
  40916. */
  40917. getSimpleName(): string;
  40918. /**
  40919. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40920. * allow modification of the heightOffset value.
  40921. */
  40922. private _modifierHeightOffset;
  40923. /**
  40924. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40925. * allow modification of the rotationOffset value.
  40926. */
  40927. private _modifierRotationOffset;
  40928. /**
  40929. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40930. * allow modification of the radius value.
  40931. */
  40932. private _modifierRadius;
  40933. }
  40934. }
  40935. declare module BABYLON {
  40936. interface FreeCameraInputsManager {
  40937. /**
  40938. * @hidden
  40939. */
  40940. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40941. /**
  40942. * Add orientation input support to the input manager.
  40943. * @returns the current input manager
  40944. */
  40945. addDeviceOrientation(): FreeCameraInputsManager;
  40946. }
  40947. /**
  40948. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40949. * Screen rotation is taken into account.
  40950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40951. */
  40952. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40953. private _camera;
  40954. private _screenOrientationAngle;
  40955. private _constantTranform;
  40956. private _screenQuaternion;
  40957. private _alpha;
  40958. private _beta;
  40959. private _gamma;
  40960. /**
  40961. * Can be used to detect if a device orientation sensor is available on a device
  40962. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40963. * @returns a promise that will resolve on orientation change
  40964. */
  40965. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40966. /**
  40967. * @hidden
  40968. */
  40969. _onDeviceOrientationChangedObservable: Observable<void>;
  40970. /**
  40971. * Instantiates a new input
  40972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40973. */
  40974. constructor();
  40975. /**
  40976. * Define the camera controlled by the input.
  40977. */
  40978. get camera(): FreeCamera;
  40979. set camera(camera: FreeCamera);
  40980. /**
  40981. * Attach the input controls to a specific dom element to get the input from.
  40982. * @param element Defines the element the controls should be listened from
  40983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40984. */
  40985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40986. private _orientationChanged;
  40987. private _deviceOrientation;
  40988. /**
  40989. * Detach the current controls from the specified dom element.
  40990. * @param element Defines the element to stop listening the inputs from
  40991. */
  40992. detachControl(element: Nullable<HTMLElement>): void;
  40993. /**
  40994. * Update the current camera state depending on the inputs that have been used this frame.
  40995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40996. */
  40997. checkInputs(): void;
  40998. /**
  40999. * Gets the class name of the current intput.
  41000. * @returns the class name
  41001. */
  41002. getClassName(): string;
  41003. /**
  41004. * Get the friendly name associated with the input class.
  41005. * @returns the input friendly name
  41006. */
  41007. getSimpleName(): string;
  41008. }
  41009. }
  41010. declare module BABYLON {
  41011. /**
  41012. * Manage the gamepad inputs to control a free camera.
  41013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41014. */
  41015. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41016. /**
  41017. * Define the camera the input is attached to.
  41018. */
  41019. camera: FreeCamera;
  41020. /**
  41021. * Define the Gamepad controlling the input
  41022. */
  41023. gamepad: Nullable<Gamepad>;
  41024. /**
  41025. * Defines the gamepad rotation sensiblity.
  41026. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41027. */
  41028. gamepadAngularSensibility: number;
  41029. /**
  41030. * Defines the gamepad move sensiblity.
  41031. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41032. */
  41033. gamepadMoveSensibility: number;
  41034. private _yAxisScale;
  41035. /**
  41036. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41037. */
  41038. get invertYAxis(): boolean;
  41039. set invertYAxis(value: boolean);
  41040. private _onGamepadConnectedObserver;
  41041. private _onGamepadDisconnectedObserver;
  41042. private _cameraTransform;
  41043. private _deltaTransform;
  41044. private _vector3;
  41045. private _vector2;
  41046. /**
  41047. * Attach the input controls to a specific dom element to get the input from.
  41048. * @param element Defines the element the controls should be listened from
  41049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41050. */
  41051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41052. /**
  41053. * Detach the current controls from the specified dom element.
  41054. * @param element Defines the element to stop listening the inputs from
  41055. */
  41056. detachControl(element: Nullable<HTMLElement>): void;
  41057. /**
  41058. * Update the current camera state depending on the inputs that have been used this frame.
  41059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41060. */
  41061. checkInputs(): void;
  41062. /**
  41063. * Gets the class name of the current intput.
  41064. * @returns the class name
  41065. */
  41066. getClassName(): string;
  41067. /**
  41068. * Get the friendly name associated with the input class.
  41069. * @returns the input friendly name
  41070. */
  41071. getSimpleName(): string;
  41072. }
  41073. }
  41074. declare module BABYLON {
  41075. /**
  41076. * Defines the potential axis of a Joystick
  41077. */
  41078. export enum JoystickAxis {
  41079. /** X axis */
  41080. X = 0,
  41081. /** Y axis */
  41082. Y = 1,
  41083. /** Z axis */
  41084. Z = 2
  41085. }
  41086. /**
  41087. * Class used to define virtual joystick (used in touch mode)
  41088. */
  41089. export class VirtualJoystick {
  41090. /**
  41091. * Gets or sets a boolean indicating that left and right values must be inverted
  41092. */
  41093. reverseLeftRight: boolean;
  41094. /**
  41095. * Gets or sets a boolean indicating that up and down values must be inverted
  41096. */
  41097. reverseUpDown: boolean;
  41098. /**
  41099. * Gets the offset value for the position (ie. the change of the position value)
  41100. */
  41101. deltaPosition: Vector3;
  41102. /**
  41103. * Gets a boolean indicating if the virtual joystick was pressed
  41104. */
  41105. pressed: boolean;
  41106. /**
  41107. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41108. */
  41109. static Canvas: Nullable<HTMLCanvasElement>;
  41110. private static _globalJoystickIndex;
  41111. private static vjCanvasContext;
  41112. private static vjCanvasWidth;
  41113. private static vjCanvasHeight;
  41114. private static halfWidth;
  41115. private _action;
  41116. private _axisTargetedByLeftAndRight;
  41117. private _axisTargetedByUpAndDown;
  41118. private _joystickSensibility;
  41119. private _inversedSensibility;
  41120. private _joystickPointerID;
  41121. private _joystickColor;
  41122. private _joystickPointerPos;
  41123. private _joystickPreviousPointerPos;
  41124. private _joystickPointerStartPos;
  41125. private _deltaJoystickVector;
  41126. private _leftJoystick;
  41127. private _touches;
  41128. private _onPointerDownHandlerRef;
  41129. private _onPointerMoveHandlerRef;
  41130. private _onPointerUpHandlerRef;
  41131. private _onResize;
  41132. /**
  41133. * Creates a new virtual joystick
  41134. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41135. */
  41136. constructor(leftJoystick?: boolean);
  41137. /**
  41138. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41139. * @param newJoystickSensibility defines the new sensibility
  41140. */
  41141. setJoystickSensibility(newJoystickSensibility: number): void;
  41142. private _onPointerDown;
  41143. private _onPointerMove;
  41144. private _onPointerUp;
  41145. /**
  41146. * Change the color of the virtual joystick
  41147. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41148. */
  41149. setJoystickColor(newColor: string): void;
  41150. /**
  41151. * Defines a callback to call when the joystick is touched
  41152. * @param action defines the callback
  41153. */
  41154. setActionOnTouch(action: () => any): void;
  41155. /**
  41156. * Defines which axis you'd like to control for left & right
  41157. * @param axis defines the axis to use
  41158. */
  41159. setAxisForLeftRight(axis: JoystickAxis): void;
  41160. /**
  41161. * Defines which axis you'd like to control for up & down
  41162. * @param axis defines the axis to use
  41163. */
  41164. setAxisForUpDown(axis: JoystickAxis): void;
  41165. private _drawVirtualJoystick;
  41166. /**
  41167. * Release internal HTML canvas
  41168. */
  41169. releaseCanvas(): void;
  41170. }
  41171. }
  41172. declare module BABYLON {
  41173. interface FreeCameraInputsManager {
  41174. /**
  41175. * Add virtual joystick input support to the input manager.
  41176. * @returns the current input manager
  41177. */
  41178. addVirtualJoystick(): FreeCameraInputsManager;
  41179. }
  41180. /**
  41181. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41183. */
  41184. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41185. /**
  41186. * Defines the camera the input is attached to.
  41187. */
  41188. camera: FreeCamera;
  41189. private _leftjoystick;
  41190. private _rightjoystick;
  41191. /**
  41192. * Gets the left stick of the virtual joystick.
  41193. * @returns The virtual Joystick
  41194. */
  41195. getLeftJoystick(): VirtualJoystick;
  41196. /**
  41197. * Gets the right stick of the virtual joystick.
  41198. * @returns The virtual Joystick
  41199. */
  41200. getRightJoystick(): VirtualJoystick;
  41201. /**
  41202. * Update the current camera state depending on the inputs that have been used this frame.
  41203. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41204. */
  41205. checkInputs(): void;
  41206. /**
  41207. * Attach the input controls to a specific dom element to get the input from.
  41208. * @param element Defines the element the controls should be listened from
  41209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41210. */
  41211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41212. /**
  41213. * Detach the current controls from the specified dom element.
  41214. * @param element Defines the element to stop listening the inputs from
  41215. */
  41216. detachControl(element: Nullable<HTMLElement>): void;
  41217. /**
  41218. * Gets the class name of the current intput.
  41219. * @returns the class name
  41220. */
  41221. getClassName(): string;
  41222. /**
  41223. * Get the friendly name associated with the input class.
  41224. * @returns the input friendly name
  41225. */
  41226. getSimpleName(): string;
  41227. }
  41228. }
  41229. declare module BABYLON {
  41230. /**
  41231. * This represents a FPS type of camera controlled by touch.
  41232. * This is like a universal camera minus the Gamepad controls.
  41233. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41234. */
  41235. export class TouchCamera extends FreeCamera {
  41236. /**
  41237. * Defines the touch sensibility for rotation.
  41238. * The higher the faster.
  41239. */
  41240. get touchAngularSensibility(): number;
  41241. set touchAngularSensibility(value: number);
  41242. /**
  41243. * Defines the touch sensibility for move.
  41244. * The higher the faster.
  41245. */
  41246. get touchMoveSensibility(): number;
  41247. set touchMoveSensibility(value: number);
  41248. /**
  41249. * Instantiates a new touch camera.
  41250. * This represents a FPS type of camera controlled by touch.
  41251. * This is like a universal camera minus the Gamepad controls.
  41252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41253. * @param name Define the name of the camera in the scene
  41254. * @param position Define the start position of the camera in the scene
  41255. * @param scene Define the scene the camera belongs to
  41256. */
  41257. constructor(name: string, position: Vector3, scene: Scene);
  41258. /**
  41259. * Gets the current object class name.
  41260. * @return the class name
  41261. */
  41262. getClassName(): string;
  41263. /** @hidden */
  41264. _setupInputs(): void;
  41265. }
  41266. }
  41267. declare module BABYLON {
  41268. /**
  41269. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41270. * being tilted forward or back and left or right.
  41271. */
  41272. export class DeviceOrientationCamera extends FreeCamera {
  41273. private _initialQuaternion;
  41274. private _quaternionCache;
  41275. private _tmpDragQuaternion;
  41276. private _disablePointerInputWhenUsingDeviceOrientation;
  41277. /**
  41278. * Creates a new device orientation camera
  41279. * @param name The name of the camera
  41280. * @param position The start position camera
  41281. * @param scene The scene the camera belongs to
  41282. */
  41283. constructor(name: string, position: Vector3, scene: Scene);
  41284. /**
  41285. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41286. */
  41287. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41288. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41289. private _dragFactor;
  41290. /**
  41291. * Enabled turning on the y axis when the orientation sensor is active
  41292. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41293. */
  41294. enableHorizontalDragging(dragFactor?: number): void;
  41295. /**
  41296. * Gets the current instance class name ("DeviceOrientationCamera").
  41297. * This helps avoiding instanceof at run time.
  41298. * @returns the class name
  41299. */
  41300. getClassName(): string;
  41301. /**
  41302. * @hidden
  41303. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41304. */
  41305. _checkInputs(): void;
  41306. /**
  41307. * Reset the camera to its default orientation on the specified axis only.
  41308. * @param axis The axis to reset
  41309. */
  41310. resetToCurrentRotation(axis?: Axis): void;
  41311. }
  41312. }
  41313. declare module BABYLON {
  41314. /**
  41315. * Defines supported buttons for XBox360 compatible gamepads
  41316. */
  41317. export enum Xbox360Button {
  41318. /** A */
  41319. A = 0,
  41320. /** B */
  41321. B = 1,
  41322. /** X */
  41323. X = 2,
  41324. /** Y */
  41325. Y = 3,
  41326. /** Left button */
  41327. LB = 4,
  41328. /** Right button */
  41329. RB = 5,
  41330. /** Back */
  41331. Back = 8,
  41332. /** Start */
  41333. Start = 9,
  41334. /** Left stick */
  41335. LeftStick = 10,
  41336. /** Right stick */
  41337. RightStick = 11
  41338. }
  41339. /** Defines values for XBox360 DPad */
  41340. export enum Xbox360Dpad {
  41341. /** Up */
  41342. Up = 12,
  41343. /** Down */
  41344. Down = 13,
  41345. /** Left */
  41346. Left = 14,
  41347. /** Right */
  41348. Right = 15
  41349. }
  41350. /**
  41351. * Defines a XBox360 gamepad
  41352. */
  41353. export class Xbox360Pad extends Gamepad {
  41354. private _leftTrigger;
  41355. private _rightTrigger;
  41356. private _onlefttriggerchanged;
  41357. private _onrighttriggerchanged;
  41358. private _onbuttondown;
  41359. private _onbuttonup;
  41360. private _ondpaddown;
  41361. private _ondpadup;
  41362. /** Observable raised when a button is pressed */
  41363. onButtonDownObservable: Observable<Xbox360Button>;
  41364. /** Observable raised when a button is released */
  41365. onButtonUpObservable: Observable<Xbox360Button>;
  41366. /** Observable raised when a pad is pressed */
  41367. onPadDownObservable: Observable<Xbox360Dpad>;
  41368. /** Observable raised when a pad is released */
  41369. onPadUpObservable: Observable<Xbox360Dpad>;
  41370. private _buttonA;
  41371. private _buttonB;
  41372. private _buttonX;
  41373. private _buttonY;
  41374. private _buttonBack;
  41375. private _buttonStart;
  41376. private _buttonLB;
  41377. private _buttonRB;
  41378. private _buttonLeftStick;
  41379. private _buttonRightStick;
  41380. private _dPadUp;
  41381. private _dPadDown;
  41382. private _dPadLeft;
  41383. private _dPadRight;
  41384. private _isXboxOnePad;
  41385. /**
  41386. * Creates a new XBox360 gamepad object
  41387. * @param id defines the id of this gamepad
  41388. * @param index defines its index
  41389. * @param gamepad defines the internal HTML gamepad object
  41390. * @param xboxOne defines if it is a XBox One gamepad
  41391. */
  41392. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41393. /**
  41394. * Defines the callback to call when left trigger is pressed
  41395. * @param callback defines the callback to use
  41396. */
  41397. onlefttriggerchanged(callback: (value: number) => void): void;
  41398. /**
  41399. * Defines the callback to call when right trigger is pressed
  41400. * @param callback defines the callback to use
  41401. */
  41402. onrighttriggerchanged(callback: (value: number) => void): void;
  41403. /**
  41404. * Gets the left trigger value
  41405. */
  41406. get leftTrigger(): number;
  41407. /**
  41408. * Sets the left trigger value
  41409. */
  41410. set leftTrigger(newValue: number);
  41411. /**
  41412. * Gets the right trigger value
  41413. */
  41414. get rightTrigger(): number;
  41415. /**
  41416. * Sets the right trigger value
  41417. */
  41418. set rightTrigger(newValue: number);
  41419. /**
  41420. * Defines the callback to call when a button is pressed
  41421. * @param callback defines the callback to use
  41422. */
  41423. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41424. /**
  41425. * Defines the callback to call when a button is released
  41426. * @param callback defines the callback to use
  41427. */
  41428. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41429. /**
  41430. * Defines the callback to call when a pad is pressed
  41431. * @param callback defines the callback to use
  41432. */
  41433. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41434. /**
  41435. * Defines the callback to call when a pad is released
  41436. * @param callback defines the callback to use
  41437. */
  41438. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41439. private _setButtonValue;
  41440. private _setDPadValue;
  41441. /**
  41442. * Gets the value of the `A` button
  41443. */
  41444. get buttonA(): number;
  41445. /**
  41446. * Sets the value of the `A` button
  41447. */
  41448. set buttonA(value: number);
  41449. /**
  41450. * Gets the value of the `B` button
  41451. */
  41452. get buttonB(): number;
  41453. /**
  41454. * Sets the value of the `B` button
  41455. */
  41456. set buttonB(value: number);
  41457. /**
  41458. * Gets the value of the `X` button
  41459. */
  41460. get buttonX(): number;
  41461. /**
  41462. * Sets the value of the `X` button
  41463. */
  41464. set buttonX(value: number);
  41465. /**
  41466. * Gets the value of the `Y` button
  41467. */
  41468. get buttonY(): number;
  41469. /**
  41470. * Sets the value of the `Y` button
  41471. */
  41472. set buttonY(value: number);
  41473. /**
  41474. * Gets the value of the `Start` button
  41475. */
  41476. get buttonStart(): number;
  41477. /**
  41478. * Sets the value of the `Start` button
  41479. */
  41480. set buttonStart(value: number);
  41481. /**
  41482. * Gets the value of the `Back` button
  41483. */
  41484. get buttonBack(): number;
  41485. /**
  41486. * Sets the value of the `Back` button
  41487. */
  41488. set buttonBack(value: number);
  41489. /**
  41490. * Gets the value of the `Left` button
  41491. */
  41492. get buttonLB(): number;
  41493. /**
  41494. * Sets the value of the `Left` button
  41495. */
  41496. set buttonLB(value: number);
  41497. /**
  41498. * Gets the value of the `Right` button
  41499. */
  41500. get buttonRB(): number;
  41501. /**
  41502. * Sets the value of the `Right` button
  41503. */
  41504. set buttonRB(value: number);
  41505. /**
  41506. * Gets the value of the Left joystick
  41507. */
  41508. get buttonLeftStick(): number;
  41509. /**
  41510. * Sets the value of the Left joystick
  41511. */
  41512. set buttonLeftStick(value: number);
  41513. /**
  41514. * Gets the value of the Right joystick
  41515. */
  41516. get buttonRightStick(): number;
  41517. /**
  41518. * Sets the value of the Right joystick
  41519. */
  41520. set buttonRightStick(value: number);
  41521. /**
  41522. * Gets the value of D-pad up
  41523. */
  41524. get dPadUp(): number;
  41525. /**
  41526. * Sets the value of D-pad up
  41527. */
  41528. set dPadUp(value: number);
  41529. /**
  41530. * Gets the value of D-pad down
  41531. */
  41532. get dPadDown(): number;
  41533. /**
  41534. * Sets the value of D-pad down
  41535. */
  41536. set dPadDown(value: number);
  41537. /**
  41538. * Gets the value of D-pad left
  41539. */
  41540. get dPadLeft(): number;
  41541. /**
  41542. * Sets the value of D-pad left
  41543. */
  41544. set dPadLeft(value: number);
  41545. /**
  41546. * Gets the value of D-pad right
  41547. */
  41548. get dPadRight(): number;
  41549. /**
  41550. * Sets the value of D-pad right
  41551. */
  41552. set dPadRight(value: number);
  41553. /**
  41554. * Force the gamepad to synchronize with device values
  41555. */
  41556. update(): void;
  41557. /**
  41558. * Disposes the gamepad
  41559. */
  41560. dispose(): void;
  41561. }
  41562. }
  41563. declare module BABYLON {
  41564. /**
  41565. * Defines supported buttons for DualShock compatible gamepads
  41566. */
  41567. export enum DualShockButton {
  41568. /** Cross */
  41569. Cross = 0,
  41570. /** Circle */
  41571. Circle = 1,
  41572. /** Square */
  41573. Square = 2,
  41574. /** Triangle */
  41575. Triangle = 3,
  41576. /** L1 */
  41577. L1 = 4,
  41578. /** R1 */
  41579. R1 = 5,
  41580. /** Share */
  41581. Share = 8,
  41582. /** Options */
  41583. Options = 9,
  41584. /** Left stick */
  41585. LeftStick = 10,
  41586. /** Right stick */
  41587. RightStick = 11
  41588. }
  41589. /** Defines values for DualShock DPad */
  41590. export enum DualShockDpad {
  41591. /** Up */
  41592. Up = 12,
  41593. /** Down */
  41594. Down = 13,
  41595. /** Left */
  41596. Left = 14,
  41597. /** Right */
  41598. Right = 15
  41599. }
  41600. /**
  41601. * Defines a DualShock gamepad
  41602. */
  41603. export class DualShockPad extends Gamepad {
  41604. private _leftTrigger;
  41605. private _rightTrigger;
  41606. private _onlefttriggerchanged;
  41607. private _onrighttriggerchanged;
  41608. private _onbuttondown;
  41609. private _onbuttonup;
  41610. private _ondpaddown;
  41611. private _ondpadup;
  41612. /** Observable raised when a button is pressed */
  41613. onButtonDownObservable: Observable<DualShockButton>;
  41614. /** Observable raised when a button is released */
  41615. onButtonUpObservable: Observable<DualShockButton>;
  41616. /** Observable raised when a pad is pressed */
  41617. onPadDownObservable: Observable<DualShockDpad>;
  41618. /** Observable raised when a pad is released */
  41619. onPadUpObservable: Observable<DualShockDpad>;
  41620. private _buttonCross;
  41621. private _buttonCircle;
  41622. private _buttonSquare;
  41623. private _buttonTriangle;
  41624. private _buttonShare;
  41625. private _buttonOptions;
  41626. private _buttonL1;
  41627. private _buttonR1;
  41628. private _buttonLeftStick;
  41629. private _buttonRightStick;
  41630. private _dPadUp;
  41631. private _dPadDown;
  41632. private _dPadLeft;
  41633. private _dPadRight;
  41634. /**
  41635. * Creates a new DualShock gamepad object
  41636. * @param id defines the id of this gamepad
  41637. * @param index defines its index
  41638. * @param gamepad defines the internal HTML gamepad object
  41639. */
  41640. constructor(id: string, index: number, gamepad: any);
  41641. /**
  41642. * Defines the callback to call when left trigger is pressed
  41643. * @param callback defines the callback to use
  41644. */
  41645. onlefttriggerchanged(callback: (value: number) => void): void;
  41646. /**
  41647. * Defines the callback to call when right trigger is pressed
  41648. * @param callback defines the callback to use
  41649. */
  41650. onrighttriggerchanged(callback: (value: number) => void): void;
  41651. /**
  41652. * Gets the left trigger value
  41653. */
  41654. get leftTrigger(): number;
  41655. /**
  41656. * Sets the left trigger value
  41657. */
  41658. set leftTrigger(newValue: number);
  41659. /**
  41660. * Gets the right trigger value
  41661. */
  41662. get rightTrigger(): number;
  41663. /**
  41664. * Sets the right trigger value
  41665. */
  41666. set rightTrigger(newValue: number);
  41667. /**
  41668. * Defines the callback to call when a button is pressed
  41669. * @param callback defines the callback to use
  41670. */
  41671. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41672. /**
  41673. * Defines the callback to call when a button is released
  41674. * @param callback defines the callback to use
  41675. */
  41676. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41677. /**
  41678. * Defines the callback to call when a pad is pressed
  41679. * @param callback defines the callback to use
  41680. */
  41681. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41682. /**
  41683. * Defines the callback to call when a pad is released
  41684. * @param callback defines the callback to use
  41685. */
  41686. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41687. private _setButtonValue;
  41688. private _setDPadValue;
  41689. /**
  41690. * Gets the value of the `Cross` button
  41691. */
  41692. get buttonCross(): number;
  41693. /**
  41694. * Sets the value of the `Cross` button
  41695. */
  41696. set buttonCross(value: number);
  41697. /**
  41698. * Gets the value of the `Circle` button
  41699. */
  41700. get buttonCircle(): number;
  41701. /**
  41702. * Sets the value of the `Circle` button
  41703. */
  41704. set buttonCircle(value: number);
  41705. /**
  41706. * Gets the value of the `Square` button
  41707. */
  41708. get buttonSquare(): number;
  41709. /**
  41710. * Sets the value of the `Square` button
  41711. */
  41712. set buttonSquare(value: number);
  41713. /**
  41714. * Gets the value of the `Triangle` button
  41715. */
  41716. get buttonTriangle(): number;
  41717. /**
  41718. * Sets the value of the `Triangle` button
  41719. */
  41720. set buttonTriangle(value: number);
  41721. /**
  41722. * Gets the value of the `Options` button
  41723. */
  41724. get buttonOptions(): number;
  41725. /**
  41726. * Sets the value of the `Options` button
  41727. */
  41728. set buttonOptions(value: number);
  41729. /**
  41730. * Gets the value of the `Share` button
  41731. */
  41732. get buttonShare(): number;
  41733. /**
  41734. * Sets the value of the `Share` button
  41735. */
  41736. set buttonShare(value: number);
  41737. /**
  41738. * Gets the value of the `L1` button
  41739. */
  41740. get buttonL1(): number;
  41741. /**
  41742. * Sets the value of the `L1` button
  41743. */
  41744. set buttonL1(value: number);
  41745. /**
  41746. * Gets the value of the `R1` button
  41747. */
  41748. get buttonR1(): number;
  41749. /**
  41750. * Sets the value of the `R1` button
  41751. */
  41752. set buttonR1(value: number);
  41753. /**
  41754. * Gets the value of the Left joystick
  41755. */
  41756. get buttonLeftStick(): number;
  41757. /**
  41758. * Sets the value of the Left joystick
  41759. */
  41760. set buttonLeftStick(value: number);
  41761. /**
  41762. * Gets the value of the Right joystick
  41763. */
  41764. get buttonRightStick(): number;
  41765. /**
  41766. * Sets the value of the Right joystick
  41767. */
  41768. set buttonRightStick(value: number);
  41769. /**
  41770. * Gets the value of D-pad up
  41771. */
  41772. get dPadUp(): number;
  41773. /**
  41774. * Sets the value of D-pad up
  41775. */
  41776. set dPadUp(value: number);
  41777. /**
  41778. * Gets the value of D-pad down
  41779. */
  41780. get dPadDown(): number;
  41781. /**
  41782. * Sets the value of D-pad down
  41783. */
  41784. set dPadDown(value: number);
  41785. /**
  41786. * Gets the value of D-pad left
  41787. */
  41788. get dPadLeft(): number;
  41789. /**
  41790. * Sets the value of D-pad left
  41791. */
  41792. set dPadLeft(value: number);
  41793. /**
  41794. * Gets the value of D-pad right
  41795. */
  41796. get dPadRight(): number;
  41797. /**
  41798. * Sets the value of D-pad right
  41799. */
  41800. set dPadRight(value: number);
  41801. /**
  41802. * Force the gamepad to synchronize with device values
  41803. */
  41804. update(): void;
  41805. /**
  41806. * Disposes the gamepad
  41807. */
  41808. dispose(): void;
  41809. }
  41810. }
  41811. declare module BABYLON {
  41812. /**
  41813. * Manager for handling gamepads
  41814. */
  41815. export class GamepadManager {
  41816. private _scene?;
  41817. private _babylonGamepads;
  41818. private _oneGamepadConnected;
  41819. /** @hidden */
  41820. _isMonitoring: boolean;
  41821. private _gamepadEventSupported;
  41822. private _gamepadSupport?;
  41823. /**
  41824. * observable to be triggered when the gamepad controller has been connected
  41825. */
  41826. onGamepadConnectedObservable: Observable<Gamepad>;
  41827. /**
  41828. * observable to be triggered when the gamepad controller has been disconnected
  41829. */
  41830. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41831. private _onGamepadConnectedEvent;
  41832. private _onGamepadDisconnectedEvent;
  41833. /**
  41834. * Initializes the gamepad manager
  41835. * @param _scene BabylonJS scene
  41836. */
  41837. constructor(_scene?: Scene | undefined);
  41838. /**
  41839. * The gamepads in the game pad manager
  41840. */
  41841. get gamepads(): Gamepad[];
  41842. /**
  41843. * Get the gamepad controllers based on type
  41844. * @param type The type of gamepad controller
  41845. * @returns Nullable gamepad
  41846. */
  41847. getGamepadByType(type?: number): Nullable<Gamepad>;
  41848. /**
  41849. * Disposes the gamepad manager
  41850. */
  41851. dispose(): void;
  41852. private _addNewGamepad;
  41853. private _startMonitoringGamepads;
  41854. private _stopMonitoringGamepads;
  41855. /** @hidden */
  41856. _checkGamepadsStatus(): void;
  41857. private _updateGamepadObjects;
  41858. }
  41859. }
  41860. declare module BABYLON {
  41861. interface Scene {
  41862. /** @hidden */
  41863. _gamepadManager: Nullable<GamepadManager>;
  41864. /**
  41865. * Gets the gamepad manager associated with the scene
  41866. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41867. */
  41868. gamepadManager: GamepadManager;
  41869. }
  41870. /**
  41871. * Interface representing a free camera inputs manager
  41872. */
  41873. interface FreeCameraInputsManager {
  41874. /**
  41875. * Adds gamepad input support to the FreeCameraInputsManager.
  41876. * @returns the FreeCameraInputsManager
  41877. */
  41878. addGamepad(): FreeCameraInputsManager;
  41879. }
  41880. /**
  41881. * Interface representing an arc rotate camera inputs manager
  41882. */
  41883. interface ArcRotateCameraInputsManager {
  41884. /**
  41885. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41886. * @returns the camera inputs manager
  41887. */
  41888. addGamepad(): ArcRotateCameraInputsManager;
  41889. }
  41890. /**
  41891. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41892. */
  41893. export class GamepadSystemSceneComponent implements ISceneComponent {
  41894. /**
  41895. * The component name helpfull to identify the component in the list of scene components.
  41896. */
  41897. readonly name: string;
  41898. /**
  41899. * The scene the component belongs to.
  41900. */
  41901. scene: Scene;
  41902. /**
  41903. * Creates a new instance of the component for the given scene
  41904. * @param scene Defines the scene to register the component in
  41905. */
  41906. constructor(scene: Scene);
  41907. /**
  41908. * Registers the component in a given scene
  41909. */
  41910. register(): void;
  41911. /**
  41912. * Rebuilds the elements related to this component in case of
  41913. * context lost for instance.
  41914. */
  41915. rebuild(): void;
  41916. /**
  41917. * Disposes the component and the associated ressources
  41918. */
  41919. dispose(): void;
  41920. private _beforeCameraUpdate;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. /**
  41925. * 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,
  41926. * which still works and will still be found in many Playgrounds.
  41927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41928. */
  41929. export class UniversalCamera extends TouchCamera {
  41930. /**
  41931. * Defines the gamepad rotation sensiblity.
  41932. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41933. */
  41934. get gamepadAngularSensibility(): number;
  41935. set gamepadAngularSensibility(value: number);
  41936. /**
  41937. * Defines the gamepad move sensiblity.
  41938. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41939. */
  41940. get gamepadMoveSensibility(): number;
  41941. set gamepadMoveSensibility(value: number);
  41942. /**
  41943. * 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,
  41944. * which still works and will still be found in many Playgrounds.
  41945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41946. * @param name Define the name of the camera in the scene
  41947. * @param position Define the start position of the camera in the scene
  41948. * @param scene Define the scene the camera belongs to
  41949. */
  41950. constructor(name: string, position: Vector3, scene: Scene);
  41951. /**
  41952. * Gets the current object class name.
  41953. * @return the class name
  41954. */
  41955. getClassName(): string;
  41956. }
  41957. }
  41958. declare module BABYLON {
  41959. /**
  41960. * This represents a FPS type of camera. This is only here for back compat purpose.
  41961. * Please use the UniversalCamera instead as both are identical.
  41962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41963. */
  41964. export class GamepadCamera extends UniversalCamera {
  41965. /**
  41966. * Instantiates a new Gamepad Camera
  41967. * This represents a FPS type of camera. This is only here for back compat purpose.
  41968. * Please use the UniversalCamera instead as both are identical.
  41969. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41970. * @param name Define the name of the camera in the scene
  41971. * @param position Define the start position of the camera in the scene
  41972. * @param scene Define the scene the camera belongs to
  41973. */
  41974. constructor(name: string, position: Vector3, scene: Scene);
  41975. /**
  41976. * Gets the current object class name.
  41977. * @return the class name
  41978. */
  41979. getClassName(): string;
  41980. }
  41981. }
  41982. declare module BABYLON {
  41983. /** @hidden */
  41984. export var passPixelShader: {
  41985. name: string;
  41986. shader: string;
  41987. };
  41988. }
  41989. declare module BABYLON {
  41990. /** @hidden */
  41991. export var passCubePixelShader: {
  41992. name: string;
  41993. shader: string;
  41994. };
  41995. }
  41996. declare module BABYLON {
  41997. /**
  41998. * PassPostProcess which produces an output the same as it's input
  41999. */
  42000. export class PassPostProcess extends PostProcess {
  42001. /**
  42002. * Creates the PassPostProcess
  42003. * @param name The name of the effect.
  42004. * @param options The required width/height ratio to downsize to before computing the render pass.
  42005. * @param camera The camera to apply the render pass to.
  42006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42007. * @param engine The engine which the post process will be applied. (default: current engine)
  42008. * @param reusable If the post process can be reused on the same frame. (default: false)
  42009. * @param textureType The type of texture to be used when performing the post processing.
  42010. * @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)
  42011. */
  42012. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42013. }
  42014. /**
  42015. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42016. */
  42017. export class PassCubePostProcess extends PostProcess {
  42018. private _face;
  42019. /**
  42020. * Gets or sets the cube face to display.
  42021. * * 0 is +X
  42022. * * 1 is -X
  42023. * * 2 is +Y
  42024. * * 3 is -Y
  42025. * * 4 is +Z
  42026. * * 5 is -Z
  42027. */
  42028. get face(): number;
  42029. set face(value: number);
  42030. /**
  42031. * Creates the PassCubePostProcess
  42032. * @param name The name of the effect.
  42033. * @param options The required width/height ratio to downsize to before computing the render pass.
  42034. * @param camera The camera to apply the render pass to.
  42035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42036. * @param engine The engine which the post process will be applied. (default: current engine)
  42037. * @param reusable If the post process can be reused on the same frame. (default: false)
  42038. * @param textureType The type of texture to be used when performing the post processing.
  42039. * @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)
  42040. */
  42041. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42042. }
  42043. }
  42044. declare module BABYLON {
  42045. /** @hidden */
  42046. export var anaglyphPixelShader: {
  42047. name: string;
  42048. shader: string;
  42049. };
  42050. }
  42051. declare module BABYLON {
  42052. /**
  42053. * Postprocess used to generate anaglyphic rendering
  42054. */
  42055. export class AnaglyphPostProcess extends PostProcess {
  42056. private _passedProcess;
  42057. /**
  42058. * Creates a new AnaglyphPostProcess
  42059. * @param name defines postprocess name
  42060. * @param options defines creation options or target ratio scale
  42061. * @param rigCameras defines cameras using this postprocess
  42062. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42063. * @param engine defines hosting engine
  42064. * @param reusable defines if the postprocess will be reused multiple times per frame
  42065. */
  42066. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42067. }
  42068. }
  42069. declare module BABYLON {
  42070. /**
  42071. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42072. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42073. */
  42074. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42075. /**
  42076. * Creates a new AnaglyphArcRotateCamera
  42077. * @param name defines camera name
  42078. * @param alpha defines alpha angle (in radians)
  42079. * @param beta defines beta angle (in radians)
  42080. * @param radius defines radius
  42081. * @param target defines camera target
  42082. * @param interaxialDistance defines distance between each color axis
  42083. * @param scene defines the hosting scene
  42084. */
  42085. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42086. /**
  42087. * Gets camera class name
  42088. * @returns AnaglyphArcRotateCamera
  42089. */
  42090. getClassName(): string;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42096. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42097. */
  42098. export class AnaglyphFreeCamera extends FreeCamera {
  42099. /**
  42100. * Creates a new AnaglyphFreeCamera
  42101. * @param name defines camera name
  42102. * @param position defines initial position
  42103. * @param interaxialDistance defines distance between each color axis
  42104. * @param scene defines the hosting scene
  42105. */
  42106. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42107. /**
  42108. * Gets camera class name
  42109. * @returns AnaglyphFreeCamera
  42110. */
  42111. getClassName(): string;
  42112. }
  42113. }
  42114. declare module BABYLON {
  42115. /**
  42116. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42117. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42118. */
  42119. export class AnaglyphGamepadCamera extends GamepadCamera {
  42120. /**
  42121. * Creates a new AnaglyphGamepadCamera
  42122. * @param name defines camera name
  42123. * @param position defines initial position
  42124. * @param interaxialDistance defines distance between each color axis
  42125. * @param scene defines the hosting scene
  42126. */
  42127. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42128. /**
  42129. * Gets camera class name
  42130. * @returns AnaglyphGamepadCamera
  42131. */
  42132. getClassName(): string;
  42133. }
  42134. }
  42135. declare module BABYLON {
  42136. /**
  42137. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42138. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42139. */
  42140. export class AnaglyphUniversalCamera extends UniversalCamera {
  42141. /**
  42142. * Creates a new AnaglyphUniversalCamera
  42143. * @param name defines camera name
  42144. * @param position defines initial position
  42145. * @param interaxialDistance defines distance between each color axis
  42146. * @param scene defines the hosting scene
  42147. */
  42148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42149. /**
  42150. * Gets camera class name
  42151. * @returns AnaglyphUniversalCamera
  42152. */
  42153. getClassName(): string;
  42154. }
  42155. }
  42156. declare module BABYLON {
  42157. /** @hidden */
  42158. export var stereoscopicInterlacePixelShader: {
  42159. name: string;
  42160. shader: string;
  42161. };
  42162. }
  42163. declare module BABYLON {
  42164. /**
  42165. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42166. */
  42167. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42168. private _stepSize;
  42169. private _passedProcess;
  42170. /**
  42171. * Initializes a StereoscopicInterlacePostProcessI
  42172. * @param name The name of the effect.
  42173. * @param rigCameras The rig cameras to be appled to the post process
  42174. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42175. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42177. * @param engine The engine which the post process will be applied. (default: current engine)
  42178. * @param reusable If the post process can be reused on the same frame. (default: false)
  42179. */
  42180. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42181. }
  42182. /**
  42183. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42184. */
  42185. export class StereoscopicInterlacePostProcess extends PostProcess {
  42186. private _stepSize;
  42187. private _passedProcess;
  42188. /**
  42189. * Initializes a StereoscopicInterlacePostProcess
  42190. * @param name The name of the effect.
  42191. * @param rigCameras The rig cameras to be appled to the post process
  42192. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42194. * @param engine The engine which the post process will be applied. (default: current engine)
  42195. * @param reusable If the post process can be reused on the same frame. (default: false)
  42196. */
  42197. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42203. * @see http://doc.babylonjs.com/features/cameras
  42204. */
  42205. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42206. /**
  42207. * Creates a new StereoscopicArcRotateCamera
  42208. * @param name defines camera name
  42209. * @param alpha defines alpha angle (in radians)
  42210. * @param beta defines beta angle (in radians)
  42211. * @param radius defines radius
  42212. * @param target defines camera target
  42213. * @param interaxialDistance defines distance between each color axis
  42214. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42215. * @param scene defines the hosting scene
  42216. */
  42217. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42218. /**
  42219. * Gets camera class name
  42220. * @returns StereoscopicArcRotateCamera
  42221. */
  42222. getClassName(): string;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /**
  42227. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42228. * @see http://doc.babylonjs.com/features/cameras
  42229. */
  42230. export class StereoscopicFreeCamera extends FreeCamera {
  42231. /**
  42232. * Creates a new StereoscopicFreeCamera
  42233. * @param name defines camera name
  42234. * @param position defines initial position
  42235. * @param interaxialDistance defines distance between each color axis
  42236. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42237. * @param scene defines the hosting scene
  42238. */
  42239. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42240. /**
  42241. * Gets camera class name
  42242. * @returns StereoscopicFreeCamera
  42243. */
  42244. getClassName(): string;
  42245. }
  42246. }
  42247. declare module BABYLON {
  42248. /**
  42249. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42250. * @see http://doc.babylonjs.com/features/cameras
  42251. */
  42252. export class StereoscopicGamepadCamera extends GamepadCamera {
  42253. /**
  42254. * Creates a new StereoscopicGamepadCamera
  42255. * @param name defines camera name
  42256. * @param position defines initial position
  42257. * @param interaxialDistance defines distance between each color axis
  42258. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42259. * @param scene defines the hosting scene
  42260. */
  42261. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42262. /**
  42263. * Gets camera class name
  42264. * @returns StereoscopicGamepadCamera
  42265. */
  42266. getClassName(): string;
  42267. }
  42268. }
  42269. declare module BABYLON {
  42270. /**
  42271. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42272. * @see http://doc.babylonjs.com/features/cameras
  42273. */
  42274. export class StereoscopicUniversalCamera extends UniversalCamera {
  42275. /**
  42276. * Creates a new StereoscopicUniversalCamera
  42277. * @param name defines camera name
  42278. * @param position defines initial position
  42279. * @param interaxialDistance defines distance between each color axis
  42280. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42281. * @param scene defines the hosting scene
  42282. */
  42283. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42284. /**
  42285. * Gets camera class name
  42286. * @returns StereoscopicUniversalCamera
  42287. */
  42288. getClassName(): string;
  42289. }
  42290. }
  42291. declare module BABYLON {
  42292. /**
  42293. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42294. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42295. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42296. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42297. */
  42298. export class VirtualJoysticksCamera extends FreeCamera {
  42299. /**
  42300. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42301. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42302. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42303. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42304. * @param name Define the name of the camera in the scene
  42305. * @param position Define the start position of the camera in the scene
  42306. * @param scene Define the scene the camera belongs to
  42307. */
  42308. constructor(name: string, position: Vector3, scene: Scene);
  42309. /**
  42310. * Gets the current object class name.
  42311. * @return the class name
  42312. */
  42313. getClassName(): string;
  42314. }
  42315. }
  42316. declare module BABYLON {
  42317. /**
  42318. * This represents all the required metrics to create a VR camera.
  42319. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42320. */
  42321. export class VRCameraMetrics {
  42322. /**
  42323. * Define the horizontal resolution off the screen.
  42324. */
  42325. hResolution: number;
  42326. /**
  42327. * Define the vertical resolution off the screen.
  42328. */
  42329. vResolution: number;
  42330. /**
  42331. * Define the horizontal screen size.
  42332. */
  42333. hScreenSize: number;
  42334. /**
  42335. * Define the vertical screen size.
  42336. */
  42337. vScreenSize: number;
  42338. /**
  42339. * Define the vertical screen center position.
  42340. */
  42341. vScreenCenter: number;
  42342. /**
  42343. * Define the distance of the eyes to the screen.
  42344. */
  42345. eyeToScreenDistance: number;
  42346. /**
  42347. * Define the distance between both lenses
  42348. */
  42349. lensSeparationDistance: number;
  42350. /**
  42351. * Define the distance between both viewer's eyes.
  42352. */
  42353. interpupillaryDistance: number;
  42354. /**
  42355. * Define the distortion factor of the VR postprocess.
  42356. * Please, touch with care.
  42357. */
  42358. distortionK: number[];
  42359. /**
  42360. * Define the chromatic aberration correction factors for the VR post process.
  42361. */
  42362. chromaAbCorrection: number[];
  42363. /**
  42364. * Define the scale factor of the post process.
  42365. * The smaller the better but the slower.
  42366. */
  42367. postProcessScaleFactor: number;
  42368. /**
  42369. * Define an offset for the lens center.
  42370. */
  42371. lensCenterOffset: number;
  42372. /**
  42373. * Define if the current vr camera should compensate the distortion of the lense or not.
  42374. */
  42375. compensateDistortion: boolean;
  42376. /**
  42377. * Defines if multiview should be enabled when rendering (Default: false)
  42378. */
  42379. multiviewEnabled: boolean;
  42380. /**
  42381. * Gets the rendering aspect ratio based on the provided resolutions.
  42382. */
  42383. get aspectRatio(): number;
  42384. /**
  42385. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42386. */
  42387. get aspectRatioFov(): number;
  42388. /**
  42389. * @hidden
  42390. */
  42391. get leftHMatrix(): Matrix;
  42392. /**
  42393. * @hidden
  42394. */
  42395. get rightHMatrix(): Matrix;
  42396. /**
  42397. * @hidden
  42398. */
  42399. get leftPreViewMatrix(): Matrix;
  42400. /**
  42401. * @hidden
  42402. */
  42403. get rightPreViewMatrix(): Matrix;
  42404. /**
  42405. * Get the default VRMetrics based on the most generic setup.
  42406. * @returns the default vr metrics
  42407. */
  42408. static GetDefault(): VRCameraMetrics;
  42409. }
  42410. }
  42411. declare module BABYLON {
  42412. /** @hidden */
  42413. export var vrDistortionCorrectionPixelShader: {
  42414. name: string;
  42415. shader: string;
  42416. };
  42417. }
  42418. declare module BABYLON {
  42419. /**
  42420. * VRDistortionCorrectionPostProcess used for mobile VR
  42421. */
  42422. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42423. private _isRightEye;
  42424. private _distortionFactors;
  42425. private _postProcessScaleFactor;
  42426. private _lensCenterOffset;
  42427. private _scaleIn;
  42428. private _scaleFactor;
  42429. private _lensCenter;
  42430. /**
  42431. * Initializes the VRDistortionCorrectionPostProcess
  42432. * @param name The name of the effect.
  42433. * @param camera The camera to apply the render pass to.
  42434. * @param isRightEye If this is for the right eye distortion
  42435. * @param vrMetrics All the required metrics for the VR camera
  42436. */
  42437. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42438. }
  42439. }
  42440. declare module BABYLON {
  42441. /**
  42442. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42443. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42444. */
  42445. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42446. /**
  42447. * Creates a new VRDeviceOrientationArcRotateCamera
  42448. * @param name defines camera name
  42449. * @param alpha defines the camera rotation along the logitudinal axis
  42450. * @param beta defines the camera rotation along the latitudinal axis
  42451. * @param radius defines the camera distance from its target
  42452. * @param target defines the camera target
  42453. * @param scene defines the scene the camera belongs to
  42454. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42455. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42456. */
  42457. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42458. /**
  42459. * Gets camera class name
  42460. * @returns VRDeviceOrientationArcRotateCamera
  42461. */
  42462. getClassName(): string;
  42463. }
  42464. }
  42465. declare module BABYLON {
  42466. /**
  42467. * Camera used to simulate VR rendering (based on FreeCamera)
  42468. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42469. */
  42470. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42471. /**
  42472. * Creates a new VRDeviceOrientationFreeCamera
  42473. * @param name defines camera name
  42474. * @param position defines the start position of the camera
  42475. * @param scene defines the scene the camera belongs to
  42476. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42477. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42478. */
  42479. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42480. /**
  42481. * Gets camera class name
  42482. * @returns VRDeviceOrientationFreeCamera
  42483. */
  42484. getClassName(): string;
  42485. }
  42486. }
  42487. declare module BABYLON {
  42488. /**
  42489. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42490. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42491. */
  42492. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42493. /**
  42494. * Creates a new VRDeviceOrientationGamepadCamera
  42495. * @param name defines camera name
  42496. * @param position defines the start position of the camera
  42497. * @param scene defines the scene the camera belongs to
  42498. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42499. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42500. */
  42501. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42502. /**
  42503. * Gets camera class name
  42504. * @returns VRDeviceOrientationGamepadCamera
  42505. */
  42506. getClassName(): string;
  42507. }
  42508. }
  42509. declare module BABYLON {
  42510. /** @hidden */
  42511. export var imageProcessingPixelShader: {
  42512. name: string;
  42513. shader: string;
  42514. };
  42515. }
  42516. declare module BABYLON {
  42517. /**
  42518. * ImageProcessingPostProcess
  42519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42520. */
  42521. export class ImageProcessingPostProcess extends PostProcess {
  42522. /**
  42523. * Default configuration related to image processing available in the PBR Material.
  42524. */
  42525. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42526. /**
  42527. * Gets the image processing configuration used either in this material.
  42528. */
  42529. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42530. /**
  42531. * Sets the Default image processing configuration used either in the this material.
  42532. *
  42533. * If sets to null, the scene one is in use.
  42534. */
  42535. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42536. /**
  42537. * Keep track of the image processing observer to allow dispose and replace.
  42538. */
  42539. private _imageProcessingObserver;
  42540. /**
  42541. * Attaches a new image processing configuration to the PBR Material.
  42542. * @param configuration
  42543. */
  42544. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42545. /**
  42546. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42547. */
  42548. get colorCurves(): Nullable<ColorCurves>;
  42549. /**
  42550. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42551. */
  42552. set colorCurves(value: Nullable<ColorCurves>);
  42553. /**
  42554. * Gets wether the color curves effect is enabled.
  42555. */
  42556. get colorCurvesEnabled(): boolean;
  42557. /**
  42558. * Sets wether the color curves effect is enabled.
  42559. */
  42560. set colorCurvesEnabled(value: boolean);
  42561. /**
  42562. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42563. */
  42564. get colorGradingTexture(): Nullable<BaseTexture>;
  42565. /**
  42566. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42567. */
  42568. set colorGradingTexture(value: Nullable<BaseTexture>);
  42569. /**
  42570. * Gets wether the color grading effect is enabled.
  42571. */
  42572. get colorGradingEnabled(): boolean;
  42573. /**
  42574. * Gets wether the color grading effect is enabled.
  42575. */
  42576. set colorGradingEnabled(value: boolean);
  42577. /**
  42578. * Gets exposure used in the effect.
  42579. */
  42580. get exposure(): number;
  42581. /**
  42582. * Sets exposure used in the effect.
  42583. */
  42584. set exposure(value: number);
  42585. /**
  42586. * Gets wether tonemapping is enabled or not.
  42587. */
  42588. get toneMappingEnabled(): boolean;
  42589. /**
  42590. * Sets wether tonemapping is enabled or not
  42591. */
  42592. set toneMappingEnabled(value: boolean);
  42593. /**
  42594. * Gets the type of tone mapping effect.
  42595. */
  42596. get toneMappingType(): number;
  42597. /**
  42598. * Sets the type of tone mapping effect.
  42599. */
  42600. set toneMappingType(value: number);
  42601. /**
  42602. * Gets contrast used in the effect.
  42603. */
  42604. get contrast(): number;
  42605. /**
  42606. * Sets contrast used in the effect.
  42607. */
  42608. set contrast(value: number);
  42609. /**
  42610. * Gets Vignette stretch size.
  42611. */
  42612. get vignetteStretch(): number;
  42613. /**
  42614. * Sets Vignette stretch size.
  42615. */
  42616. set vignetteStretch(value: number);
  42617. /**
  42618. * Gets Vignette centre X Offset.
  42619. */
  42620. get vignetteCentreX(): number;
  42621. /**
  42622. * Sets Vignette centre X Offset.
  42623. */
  42624. set vignetteCentreX(value: number);
  42625. /**
  42626. * Gets Vignette centre Y Offset.
  42627. */
  42628. get vignetteCentreY(): number;
  42629. /**
  42630. * Sets Vignette centre Y Offset.
  42631. */
  42632. set vignetteCentreY(value: number);
  42633. /**
  42634. * Gets Vignette weight or intensity of the vignette effect.
  42635. */
  42636. get vignetteWeight(): number;
  42637. /**
  42638. * Sets Vignette weight or intensity of the vignette effect.
  42639. */
  42640. set vignetteWeight(value: number);
  42641. /**
  42642. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42643. * if vignetteEnabled is set to true.
  42644. */
  42645. get vignetteColor(): Color4;
  42646. /**
  42647. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42648. * if vignetteEnabled is set to true.
  42649. */
  42650. set vignetteColor(value: Color4);
  42651. /**
  42652. * Gets Camera field of view used by the Vignette effect.
  42653. */
  42654. get vignetteCameraFov(): number;
  42655. /**
  42656. * Sets Camera field of view used by the Vignette effect.
  42657. */
  42658. set vignetteCameraFov(value: number);
  42659. /**
  42660. * Gets the vignette blend mode allowing different kind of effect.
  42661. */
  42662. get vignetteBlendMode(): number;
  42663. /**
  42664. * Sets the vignette blend mode allowing different kind of effect.
  42665. */
  42666. set vignetteBlendMode(value: number);
  42667. /**
  42668. * Gets wether the vignette effect is enabled.
  42669. */
  42670. get vignetteEnabled(): boolean;
  42671. /**
  42672. * Sets wether the vignette effect is enabled.
  42673. */
  42674. set vignetteEnabled(value: boolean);
  42675. private _fromLinearSpace;
  42676. /**
  42677. * Gets wether the input of the processing is in Gamma or Linear Space.
  42678. */
  42679. get fromLinearSpace(): boolean;
  42680. /**
  42681. * Sets wether the input of the processing is in Gamma or Linear Space.
  42682. */
  42683. set fromLinearSpace(value: boolean);
  42684. /**
  42685. * Defines cache preventing GC.
  42686. */
  42687. private _defines;
  42688. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42689. /**
  42690. * "ImageProcessingPostProcess"
  42691. * @returns "ImageProcessingPostProcess"
  42692. */
  42693. getClassName(): string;
  42694. protected _updateParameters(): void;
  42695. dispose(camera?: Camera): void;
  42696. }
  42697. }
  42698. declare module BABYLON {
  42699. /**
  42700. * Class containing static functions to help procedurally build meshes
  42701. */
  42702. export class GroundBuilder {
  42703. /**
  42704. * Creates a ground mesh
  42705. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42706. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42708. * @param name defines the name of the mesh
  42709. * @param options defines the options used to create the mesh
  42710. * @param scene defines the hosting scene
  42711. * @returns the ground mesh
  42712. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42713. */
  42714. static CreateGround(name: string, options: {
  42715. width?: number;
  42716. height?: number;
  42717. subdivisions?: number;
  42718. subdivisionsX?: number;
  42719. subdivisionsY?: number;
  42720. updatable?: boolean;
  42721. }, scene: any): Mesh;
  42722. /**
  42723. * Creates a tiled ground mesh
  42724. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42725. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42726. * * 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
  42727. * * 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
  42728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42729. * @param name defines the name of the mesh
  42730. * @param options defines the options used to create the mesh
  42731. * @param scene defines the hosting scene
  42732. * @returns the tiled ground mesh
  42733. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42734. */
  42735. static CreateTiledGround(name: string, options: {
  42736. xmin: number;
  42737. zmin: number;
  42738. xmax: number;
  42739. zmax: number;
  42740. subdivisions?: {
  42741. w: number;
  42742. h: number;
  42743. };
  42744. precision?: {
  42745. w: number;
  42746. h: number;
  42747. };
  42748. updatable?: boolean;
  42749. }, scene?: Nullable<Scene>): Mesh;
  42750. /**
  42751. * Creates a ground mesh from a height map
  42752. * * The parameter `url` sets the URL of the height map image resource.
  42753. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42754. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42755. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42756. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42757. * * 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.
  42758. * * 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).
  42759. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42761. * @param name defines the name of the mesh
  42762. * @param url defines the url to the height map
  42763. * @param options defines the options used to create the mesh
  42764. * @param scene defines the hosting scene
  42765. * @returns the ground mesh
  42766. * @see https://doc.babylonjs.com/babylon101/height_map
  42767. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42768. */
  42769. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42770. width?: number;
  42771. height?: number;
  42772. subdivisions?: number;
  42773. minHeight?: number;
  42774. maxHeight?: number;
  42775. colorFilter?: Color3;
  42776. alphaFilter?: number;
  42777. updatable?: boolean;
  42778. onReady?: (mesh: GroundMesh) => void;
  42779. }, scene?: Nullable<Scene>): GroundMesh;
  42780. }
  42781. }
  42782. declare module BABYLON {
  42783. /**
  42784. * Class containing static functions to help procedurally build meshes
  42785. */
  42786. export class TorusBuilder {
  42787. /**
  42788. * Creates a torus mesh
  42789. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42790. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42791. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42793. * * 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
  42794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42795. * @param name defines the name of the mesh
  42796. * @param options defines the options used to create the mesh
  42797. * @param scene defines the hosting scene
  42798. * @returns the torus mesh
  42799. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42800. */
  42801. static CreateTorus(name: string, options: {
  42802. diameter?: number;
  42803. thickness?: number;
  42804. tessellation?: number;
  42805. updatable?: boolean;
  42806. sideOrientation?: number;
  42807. frontUVs?: Vector4;
  42808. backUVs?: Vector4;
  42809. }, scene: any): Mesh;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. /**
  42814. * Class containing static functions to help procedurally build meshes
  42815. */
  42816. export class CylinderBuilder {
  42817. /**
  42818. * Creates a cylinder or a cone mesh
  42819. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42820. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42821. * * 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.
  42822. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42823. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42824. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42825. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42826. * * 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).
  42827. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42828. * * 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).
  42829. * * 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
  42830. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42831. * * 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
  42832. * * 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.
  42833. * * If `enclose` is false, a ring surface is one element.
  42834. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42835. * * 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
  42836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42837. * * 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
  42838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42839. * @param name defines the name of the mesh
  42840. * @param options defines the options used to create the mesh
  42841. * @param scene defines the hosting scene
  42842. * @returns the cylinder mesh
  42843. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42844. */
  42845. static CreateCylinder(name: string, options: {
  42846. height?: number;
  42847. diameterTop?: number;
  42848. diameterBottom?: number;
  42849. diameter?: number;
  42850. tessellation?: number;
  42851. subdivisions?: number;
  42852. arc?: number;
  42853. faceColors?: Color4[];
  42854. faceUV?: Vector4[];
  42855. updatable?: boolean;
  42856. hasRings?: boolean;
  42857. enclose?: boolean;
  42858. cap?: number;
  42859. sideOrientation?: number;
  42860. frontUVs?: Vector4;
  42861. backUVs?: Vector4;
  42862. }, scene: any): Mesh;
  42863. }
  42864. }
  42865. declare module BABYLON {
  42866. /**
  42867. * States of the webXR experience
  42868. */
  42869. export enum WebXRState {
  42870. /**
  42871. * Transitioning to being in XR mode
  42872. */
  42873. ENTERING_XR = 0,
  42874. /**
  42875. * Transitioning to non XR mode
  42876. */
  42877. EXITING_XR = 1,
  42878. /**
  42879. * In XR mode and presenting
  42880. */
  42881. IN_XR = 2,
  42882. /**
  42883. * Not entered XR mode
  42884. */
  42885. NOT_IN_XR = 3
  42886. }
  42887. /**
  42888. * Abstraction of the XR render target
  42889. */
  42890. export interface WebXRRenderTarget extends IDisposable {
  42891. /**
  42892. * xrpresent context of the canvas which can be used to display/mirror xr content
  42893. */
  42894. canvasContext: WebGLRenderingContext;
  42895. /**
  42896. * xr layer for the canvas
  42897. */
  42898. xrLayer: Nullable<XRWebGLLayer>;
  42899. /**
  42900. * Initializes the xr layer for the session
  42901. * @param xrSession xr session
  42902. * @returns a promise that will resolve once the XR Layer has been created
  42903. */
  42904. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42905. }
  42906. }
  42907. declare module BABYLON {
  42908. /**
  42909. * COnfiguration object for WebXR output canvas
  42910. */
  42911. export class WebXRManagedOutputCanvasOptions {
  42912. /**
  42913. * An optional canvas in case you wish to create it yourself and provide it here.
  42914. * If not provided, a new canvas will be created
  42915. */
  42916. canvasElement?: HTMLCanvasElement;
  42917. /**
  42918. * Options for this XR Layer output
  42919. */
  42920. canvasOptions?: XRWebGLLayerOptions;
  42921. /**
  42922. * CSS styling for a newly created canvas (if not provided)
  42923. */
  42924. newCanvasCssStyle?: string;
  42925. /**
  42926. * Get the default values of the configuration object
  42927. * @returns default values of this configuration object
  42928. */
  42929. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42930. }
  42931. /**
  42932. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42933. */
  42934. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42935. private _options;
  42936. private _canvas;
  42937. private _engine;
  42938. /**
  42939. * Rendering context of the canvas which can be used to display/mirror xr content
  42940. */
  42941. canvasContext: WebGLRenderingContext;
  42942. /**
  42943. * xr layer for the canvas
  42944. */
  42945. xrLayer: Nullable<XRWebGLLayer>;
  42946. /**
  42947. * Initializes the canvas to be added/removed upon entering/exiting xr
  42948. * @param _xrSessionManager The XR Session manager
  42949. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42950. */
  42951. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42952. /**
  42953. * Disposes of the object
  42954. */
  42955. dispose(): void;
  42956. /**
  42957. * Initializes the xr layer for the session
  42958. * @param xrSession xr session
  42959. * @returns a promise that will resolve once the XR Layer has been created
  42960. */
  42961. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42962. private _addCanvas;
  42963. private _removeCanvas;
  42964. private _setManagedOutputCanvas;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Manages an XRSession to work with Babylon's engine
  42970. * @see https://doc.babylonjs.com/how_to/webxr
  42971. */
  42972. export class WebXRSessionManager implements IDisposable {
  42973. /** The scene which the session should be created for */
  42974. scene: Scene;
  42975. private _referenceSpace;
  42976. private _rttProvider;
  42977. private _sessionEnded;
  42978. private _xrNavigator;
  42979. private baseLayer;
  42980. /**
  42981. * The base reference space from which the session started. good if you want to reset your
  42982. * reference space
  42983. */
  42984. baseReferenceSpace: XRReferenceSpace;
  42985. /**
  42986. * Current XR frame
  42987. */
  42988. currentFrame: Nullable<XRFrame>;
  42989. /** WebXR timestamp updated every frame */
  42990. currentTimestamp: number;
  42991. /**
  42992. * Used just in case of a failure to initialize an immersive session.
  42993. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42994. */
  42995. defaultHeightCompensation: number;
  42996. /**
  42997. * Fires every time a new xrFrame arrives which can be used to update the camera
  42998. */
  42999. onXRFrameObservable: Observable<XRFrame>;
  43000. /**
  43001. * Fires when the reference space changed
  43002. */
  43003. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43004. /**
  43005. * Fires when the xr session is ended either by the device or manually done
  43006. */
  43007. onXRSessionEnded: Observable<any>;
  43008. /**
  43009. * Fires when the xr session is ended either by the device or manually done
  43010. */
  43011. onXRSessionInit: Observable<XRSession>;
  43012. /**
  43013. * Underlying xr session
  43014. */
  43015. session: XRSession;
  43016. /**
  43017. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43018. * or get the offset the player is currently at.
  43019. */
  43020. viewerReferenceSpace: XRReferenceSpace;
  43021. /**
  43022. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43023. * @param scene The scene which the session should be created for
  43024. */
  43025. constructor(
  43026. /** The scene which the session should be created for */
  43027. scene: Scene);
  43028. /**
  43029. * The current reference space used in this session. This reference space can constantly change!
  43030. * It is mainly used to offset the camera's position.
  43031. */
  43032. get referenceSpace(): XRReferenceSpace;
  43033. /**
  43034. * Set a new reference space and triggers the observable
  43035. */
  43036. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43037. /**
  43038. * Disposes of the session manager
  43039. */
  43040. dispose(): void;
  43041. /**
  43042. * Stops the xrSession and restores the render loop
  43043. * @returns Promise which resolves after it exits XR
  43044. */
  43045. exitXRAsync(): Promise<void>;
  43046. /**
  43047. * Gets the correct render target texture to be rendered this frame for this eye
  43048. * @param eye the eye for which to get the render target
  43049. * @returns the render target for the specified eye
  43050. */
  43051. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43052. /**
  43053. * Creates a WebXRRenderTarget object for the XR session
  43054. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43055. * @param options optional options to provide when creating a new render target
  43056. * @returns a WebXR render target to which the session can render
  43057. */
  43058. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43059. /**
  43060. * Initializes the manager
  43061. * After initialization enterXR can be called to start an XR session
  43062. * @returns Promise which resolves after it is initialized
  43063. */
  43064. initializeAsync(): Promise<void>;
  43065. /**
  43066. * Initializes an xr session
  43067. * @param xrSessionMode mode to initialize
  43068. * @param xrSessionInit defines optional and required values to pass to the session builder
  43069. * @returns a promise which will resolve once the session has been initialized
  43070. */
  43071. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43072. /**
  43073. * Checks if a session would be supported for the creation options specified
  43074. * @param sessionMode session mode to check if supported eg. immersive-vr
  43075. * @returns A Promise that resolves to true if supported and false if not
  43076. */
  43077. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43078. /**
  43079. * Resets the reference space to the one started the session
  43080. */
  43081. resetReferenceSpace(): void;
  43082. /**
  43083. * Starts rendering to the xr layer
  43084. */
  43085. runXRRenderLoop(): void;
  43086. /**
  43087. * Sets the reference space on the xr session
  43088. * @param referenceSpaceType space to set
  43089. * @returns a promise that will resolve once the reference space has been set
  43090. */
  43091. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43092. /**
  43093. * Updates the render state of the session
  43094. * @param state state to set
  43095. * @returns a promise that resolves once the render state has been updated
  43096. */
  43097. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43098. /**
  43099. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43100. * @param sessionMode defines the session to test
  43101. * @returns a promise with boolean as final value
  43102. */
  43103. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43104. private _createRenderTargetTexture;
  43105. }
  43106. }
  43107. declare module BABYLON {
  43108. /**
  43109. * WebXR Camera which holds the views for the xrSession
  43110. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43111. */
  43112. export class WebXRCamera extends FreeCamera {
  43113. private _xrSessionManager;
  43114. private _firstFrame;
  43115. private _referenceQuaternion;
  43116. private _referencedPosition;
  43117. private _xrInvPositionCache;
  43118. private _xrInvQuaternionCache;
  43119. /**
  43120. * Should position compensation execute on first frame.
  43121. * This is used when copying the position from a native (non XR) camera
  43122. */
  43123. compensateOnFirstFrame: boolean;
  43124. /**
  43125. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43126. * @param name the name of the camera
  43127. * @param scene the scene to add the camera to
  43128. * @param _xrSessionManager a constructed xr session manager
  43129. */
  43130. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43131. /**
  43132. * Return the user's height, unrelated to the current ground.
  43133. * This will be the y position of this camera, when ground level is 0.
  43134. */
  43135. get realWorldHeight(): number;
  43136. /** @hidden */
  43137. _updateForDualEyeDebugging(): void;
  43138. /**
  43139. * Sets this camera's transformation based on a non-vr camera
  43140. * @param otherCamera the non-vr camera to copy the transformation from
  43141. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43142. */
  43143. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43144. /**
  43145. * Gets the current instance class name ("WebXRCamera").
  43146. * @returns the class name
  43147. */
  43148. getClassName(): string;
  43149. private _updateFromXRSession;
  43150. private _updateNumberOfRigCameras;
  43151. private _updateReferenceSpace;
  43152. private _updateReferenceSpaceOffset;
  43153. }
  43154. }
  43155. declare module BABYLON {
  43156. /**
  43157. * Defining the interface required for a (webxr) feature
  43158. */
  43159. export interface IWebXRFeature extends IDisposable {
  43160. /**
  43161. * Is this feature attached
  43162. */
  43163. attached: boolean;
  43164. /**
  43165. * Should auto-attach be disabled?
  43166. */
  43167. disableAutoAttach: boolean;
  43168. /**
  43169. * Attach the feature to the session
  43170. * Will usually be called by the features manager
  43171. *
  43172. * @param force should attachment be forced (even when already attached)
  43173. * @returns true if successful.
  43174. */
  43175. attach(force?: boolean): boolean;
  43176. /**
  43177. * Detach the feature from the session
  43178. * Will usually be called by the features manager
  43179. *
  43180. * @returns true if successful.
  43181. */
  43182. detach(): boolean;
  43183. }
  43184. /**
  43185. * A list of the currently available features without referencing them
  43186. */
  43187. export class WebXRFeatureName {
  43188. /**
  43189. * The name of the anchor system feature
  43190. */
  43191. static ANCHOR_SYSTEM: string;
  43192. /**
  43193. * The name of the background remover feature
  43194. */
  43195. static BACKGROUND_REMOVER: string;
  43196. /**
  43197. * The name of the hit test feature
  43198. */
  43199. static HIT_TEST: string;
  43200. /**
  43201. * physics impostors for xr controllers feature
  43202. */
  43203. static PHYSICS_CONTROLLERS: string;
  43204. /**
  43205. * The name of the plane detection feature
  43206. */
  43207. static PLANE_DETECTION: string;
  43208. /**
  43209. * The name of the pointer selection feature
  43210. */
  43211. static POINTER_SELECTION: string;
  43212. /**
  43213. * The name of the teleportation feature
  43214. */
  43215. static TELEPORTATION: string;
  43216. }
  43217. /**
  43218. * Defining the constructor of a feature. Used to register the modules.
  43219. */
  43220. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43221. /**
  43222. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43223. * It is mainly used in AR sessions.
  43224. *
  43225. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43226. */
  43227. export class WebXRFeaturesManager implements IDisposable {
  43228. private _xrSessionManager;
  43229. private static readonly _AvailableFeatures;
  43230. private _features;
  43231. /**
  43232. * constructs a new features manages.
  43233. *
  43234. * @param _xrSessionManager an instance of WebXRSessionManager
  43235. */
  43236. constructor(_xrSessionManager: WebXRSessionManager);
  43237. /**
  43238. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43239. * Mainly used internally.
  43240. *
  43241. * @param featureName the name of the feature to register
  43242. * @param constructorFunction the function used to construct the module
  43243. * @param version the (babylon) version of the module
  43244. * @param stable is that a stable version of this module
  43245. */
  43246. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43247. /**
  43248. * Returns a constructor of a specific feature.
  43249. *
  43250. * @param featureName the name of the feature to construct
  43251. * @param version the version of the feature to load
  43252. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43253. * @param options optional options provided to the module.
  43254. * @returns a function that, when called, will return a new instance of this feature
  43255. */
  43256. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43257. /**
  43258. * Can be used to return the list of features currently registered
  43259. *
  43260. * @returns an Array of available features
  43261. */
  43262. static GetAvailableFeatures(): string[];
  43263. /**
  43264. * Gets the versions available for a specific feature
  43265. * @param featureName the name of the feature
  43266. * @returns an array with the available versions
  43267. */
  43268. static GetAvailableVersions(featureName: string): string[];
  43269. /**
  43270. * Return the latest unstable version of this feature
  43271. * @param featureName the name of the feature to search
  43272. * @returns the version number. if not found will return -1
  43273. */
  43274. static GetLatestVersionOfFeature(featureName: string): number;
  43275. /**
  43276. * Return the latest stable version of this feature
  43277. * @param featureName the name of the feature to search
  43278. * @returns the version number. if not found will return -1
  43279. */
  43280. static GetStableVersionOfFeature(featureName: string): number;
  43281. /**
  43282. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43283. * Can be used during a session to start a feature
  43284. * @param featureName the name of feature to attach
  43285. */
  43286. attachFeature(featureName: string): void;
  43287. /**
  43288. * Can be used inside a session or when the session ends to detach a specific feature
  43289. * @param featureName the name of the feature to detach
  43290. */
  43291. detachFeature(featureName: string): void;
  43292. /**
  43293. * Used to disable an already-enabled feature
  43294. * The feature will be disposed and will be recreated once enabled.
  43295. * @param featureName the feature to disable
  43296. * @returns true if disable was successful
  43297. */
  43298. disableFeature(featureName: string | {
  43299. Name: string;
  43300. }): boolean;
  43301. /**
  43302. * dispose this features manager
  43303. */
  43304. dispose(): void;
  43305. /**
  43306. * 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.
  43307. * 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.
  43308. *
  43309. * @param featureName the name of the feature to load or the class of the feature
  43310. * @param version optional version to load. if not provided the latest version will be enabled
  43311. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43312. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43313. * @returns a new constructed feature or throws an error if feature not found.
  43314. */
  43315. enableFeature(featureName: string | {
  43316. Name: string;
  43317. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43318. /**
  43319. * get the implementation of an enabled feature.
  43320. * @param featureName the name of the feature to load
  43321. * @returns the feature class, if found
  43322. */
  43323. getEnabledFeature(featureName: string): IWebXRFeature;
  43324. /**
  43325. * Get the list of enabled features
  43326. * @returns an array of enabled features
  43327. */
  43328. getEnabledFeatures(): string[];
  43329. }
  43330. }
  43331. declare module BABYLON {
  43332. /**
  43333. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43334. * @see https://doc.babylonjs.com/how_to/webxr
  43335. */
  43336. export class WebXRExperienceHelper implements IDisposable {
  43337. private scene;
  43338. private _nonVRCamera;
  43339. private _originalSceneAutoClear;
  43340. private _supported;
  43341. /**
  43342. * Camera used to render xr content
  43343. */
  43344. camera: WebXRCamera;
  43345. /** A features manager for this xr session */
  43346. featuresManager: WebXRFeaturesManager;
  43347. /**
  43348. * Observers registered here will be triggered after the camera's initial transformation is set
  43349. * This can be used to set a different ground level or an extra rotation.
  43350. *
  43351. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43352. * to the position set after this observable is done executing.
  43353. */
  43354. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43355. /**
  43356. * Fires when the state of the experience helper has changed
  43357. */
  43358. onStateChangedObservable: Observable<WebXRState>;
  43359. /** Session manager used to keep track of xr session */
  43360. sessionManager: WebXRSessionManager;
  43361. /**
  43362. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43363. */
  43364. state: WebXRState;
  43365. /**
  43366. * Creates a WebXRExperienceHelper
  43367. * @param scene The scene the helper should be created in
  43368. */
  43369. private constructor();
  43370. /**
  43371. * Creates the experience helper
  43372. * @param scene the scene to attach the experience helper to
  43373. * @returns a promise for the experience helper
  43374. */
  43375. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43376. /**
  43377. * Disposes of the experience helper
  43378. */
  43379. dispose(): void;
  43380. /**
  43381. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43382. * @param sessionMode options for the XR session
  43383. * @param referenceSpaceType frame of reference of the XR session
  43384. * @param renderTarget the output canvas that will be used to enter XR mode
  43385. * @returns promise that resolves after xr mode has entered
  43386. */
  43387. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43388. /**
  43389. * Exits XR mode and returns the scene to its original state
  43390. * @returns promise that resolves after xr mode has exited
  43391. */
  43392. exitXRAsync(): Promise<void>;
  43393. private _nonXRToXRCamera;
  43394. private _setState;
  43395. }
  43396. }
  43397. declare module BABYLON {
  43398. /**
  43399. * X-Y values for axes in WebXR
  43400. */
  43401. export interface IWebXRMotionControllerAxesValue {
  43402. /**
  43403. * The value of the x axis
  43404. */
  43405. x: number;
  43406. /**
  43407. * The value of the y-axis
  43408. */
  43409. y: number;
  43410. }
  43411. /**
  43412. * changed / previous values for the values of this component
  43413. */
  43414. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43415. /**
  43416. * current (this frame) value
  43417. */
  43418. current: T;
  43419. /**
  43420. * previous (last change) value
  43421. */
  43422. previous: T;
  43423. }
  43424. /**
  43425. * Represents changes in the component between current frame and last values recorded
  43426. */
  43427. export interface IWebXRMotionControllerComponentChanges {
  43428. /**
  43429. * will be populated with previous and current values if axes changed
  43430. */
  43431. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43432. /**
  43433. * will be populated with previous and current values if pressed changed
  43434. */
  43435. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43436. /**
  43437. * will be populated with previous and current values if touched changed
  43438. */
  43439. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43440. /**
  43441. * will be populated with previous and current values if value changed
  43442. */
  43443. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43444. }
  43445. /**
  43446. * This class represents a single component (for example button or thumbstick) of a motion controller
  43447. */
  43448. export class WebXRControllerComponent implements IDisposable {
  43449. /**
  43450. * the id of this component
  43451. */
  43452. id: string;
  43453. /**
  43454. * the type of the component
  43455. */
  43456. type: MotionControllerComponentType;
  43457. private _buttonIndex;
  43458. private _axesIndices;
  43459. private _axes;
  43460. private _changes;
  43461. private _currentValue;
  43462. private _hasChanges;
  43463. private _pressed;
  43464. private _touched;
  43465. /**
  43466. * button component type
  43467. */
  43468. static BUTTON_TYPE: MotionControllerComponentType;
  43469. /**
  43470. * squeeze component type
  43471. */
  43472. static SQUEEZE_TYPE: MotionControllerComponentType;
  43473. /**
  43474. * Thumbstick component type
  43475. */
  43476. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43477. /**
  43478. * Touchpad component type
  43479. */
  43480. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43481. /**
  43482. * trigger component type
  43483. */
  43484. static TRIGGER_TYPE: MotionControllerComponentType;
  43485. /**
  43486. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43487. * the axes data changes
  43488. */
  43489. onAxisValueChangedObservable: Observable<{
  43490. x: number;
  43491. y: number;
  43492. }>;
  43493. /**
  43494. * Observers registered here will be triggered when the state of a button changes
  43495. * State change is either pressed / touched / value
  43496. */
  43497. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43498. /**
  43499. * Creates a new component for a motion controller.
  43500. * It is created by the motion controller itself
  43501. *
  43502. * @param id the id of this component
  43503. * @param type the type of the component
  43504. * @param _buttonIndex index in the buttons array of the gamepad
  43505. * @param _axesIndices indices of the values in the axes array of the gamepad
  43506. */
  43507. constructor(
  43508. /**
  43509. * the id of this component
  43510. */
  43511. id: string,
  43512. /**
  43513. * the type of the component
  43514. */
  43515. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43516. /**
  43517. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43518. */
  43519. get axes(): IWebXRMotionControllerAxesValue;
  43520. /**
  43521. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43522. */
  43523. get changes(): IWebXRMotionControllerComponentChanges;
  43524. /**
  43525. * Return whether or not the component changed the last frame
  43526. */
  43527. get hasChanges(): boolean;
  43528. /**
  43529. * is the button currently pressed
  43530. */
  43531. get pressed(): boolean;
  43532. /**
  43533. * is the button currently touched
  43534. */
  43535. get touched(): boolean;
  43536. /**
  43537. * Get the current value of this component
  43538. */
  43539. get value(): number;
  43540. /**
  43541. * Dispose this component
  43542. */
  43543. dispose(): void;
  43544. /**
  43545. * Are there axes correlating to this component
  43546. * @return true is axes data is available
  43547. */
  43548. isAxes(): boolean;
  43549. /**
  43550. * Is this component a button (hence - pressable)
  43551. * @returns true if can be pressed
  43552. */
  43553. isButton(): boolean;
  43554. /**
  43555. * update this component using the gamepad object it is in. Called on every frame
  43556. * @param nativeController the native gamepad controller object
  43557. */
  43558. update(nativeController: IMinimalMotionControllerObject): void;
  43559. }
  43560. }
  43561. declare module BABYLON {
  43562. /**
  43563. * Class used to represent data loading progression
  43564. */
  43565. export class SceneLoaderProgressEvent {
  43566. /** defines if data length to load can be evaluated */
  43567. readonly lengthComputable: boolean;
  43568. /** defines the loaded data length */
  43569. readonly loaded: number;
  43570. /** defines the data length to load */
  43571. readonly total: number;
  43572. /**
  43573. * Create a new progress event
  43574. * @param lengthComputable defines if data length to load can be evaluated
  43575. * @param loaded defines the loaded data length
  43576. * @param total defines the data length to load
  43577. */
  43578. constructor(
  43579. /** defines if data length to load can be evaluated */
  43580. lengthComputable: boolean,
  43581. /** defines the loaded data length */
  43582. loaded: number,
  43583. /** defines the data length to load */
  43584. total: number);
  43585. /**
  43586. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43587. * @param event defines the source event
  43588. * @returns a new SceneLoaderProgressEvent
  43589. */
  43590. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43591. }
  43592. /**
  43593. * Interface used by SceneLoader plugins to define supported file extensions
  43594. */
  43595. export interface ISceneLoaderPluginExtensions {
  43596. /**
  43597. * Defines the list of supported extensions
  43598. */
  43599. [extension: string]: {
  43600. isBinary: boolean;
  43601. };
  43602. }
  43603. /**
  43604. * Interface used by SceneLoader plugin factory
  43605. */
  43606. export interface ISceneLoaderPluginFactory {
  43607. /**
  43608. * Defines the name of the factory
  43609. */
  43610. name: string;
  43611. /**
  43612. * Function called to create a new plugin
  43613. * @return the new plugin
  43614. */
  43615. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43616. /**
  43617. * The callback that returns true if the data can be directly loaded.
  43618. * @param data string containing the file data
  43619. * @returns if the data can be loaded directly
  43620. */
  43621. canDirectLoad?(data: string): boolean;
  43622. }
  43623. /**
  43624. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43625. */
  43626. export interface ISceneLoaderPluginBase {
  43627. /**
  43628. * The friendly name of this plugin.
  43629. */
  43630. name: string;
  43631. /**
  43632. * The file extensions supported by this plugin.
  43633. */
  43634. extensions: string | ISceneLoaderPluginExtensions;
  43635. /**
  43636. * The callback called when loading from a url.
  43637. * @param scene scene loading this url
  43638. * @param url url to load
  43639. * @param onSuccess callback called when the file successfully loads
  43640. * @param onProgress callback called while file is loading (if the server supports this mode)
  43641. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43642. * @param onError callback called when the file fails to load
  43643. * @returns a file request object
  43644. */
  43645. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43646. /**
  43647. * The callback called when loading from a file object.
  43648. * @param scene scene loading this file
  43649. * @param file defines the file to load
  43650. * @param onSuccess defines the callback to call when data is loaded
  43651. * @param onProgress defines the callback to call during loading process
  43652. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43653. * @param onError defines the callback to call when an error occurs
  43654. * @returns a file request object
  43655. */
  43656. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43657. /**
  43658. * The callback that returns true if the data can be directly loaded.
  43659. * @param data string containing the file data
  43660. * @returns if the data can be loaded directly
  43661. */
  43662. canDirectLoad?(data: string): boolean;
  43663. /**
  43664. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43665. * @param scene scene loading this data
  43666. * @param data string containing the data
  43667. * @returns data to pass to the plugin
  43668. */
  43669. directLoad?(scene: Scene, data: string): any;
  43670. /**
  43671. * The callback that allows custom handling of the root url based on the response url.
  43672. * @param rootUrl the original root url
  43673. * @param responseURL the response url if available
  43674. * @returns the new root url
  43675. */
  43676. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43677. }
  43678. /**
  43679. * Interface used to define a SceneLoader plugin
  43680. */
  43681. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43682. /**
  43683. * Import meshes into a scene.
  43684. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43685. * @param scene The scene to import into
  43686. * @param data The data to import
  43687. * @param rootUrl The root url for scene and resources
  43688. * @param meshes The meshes array to import into
  43689. * @param particleSystems The particle systems array to import into
  43690. * @param skeletons The skeletons array to import into
  43691. * @param onError The callback when import fails
  43692. * @returns True if successful or false otherwise
  43693. */
  43694. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43695. /**
  43696. * Load into a scene.
  43697. * @param scene The scene to load into
  43698. * @param data The data to import
  43699. * @param rootUrl The root url for scene and resources
  43700. * @param onError The callback when import fails
  43701. * @returns True if successful or false otherwise
  43702. */
  43703. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43704. /**
  43705. * Load into an asset container.
  43706. * @param scene The scene to load into
  43707. * @param data The data to import
  43708. * @param rootUrl The root url for scene and resources
  43709. * @param onError The callback when import fails
  43710. * @returns The loaded asset container
  43711. */
  43712. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43713. }
  43714. /**
  43715. * Interface used to define an async SceneLoader plugin
  43716. */
  43717. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43718. /**
  43719. * Import meshes into a scene.
  43720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43721. * @param scene The scene to import into
  43722. * @param data The data to import
  43723. * @param rootUrl The root url for scene and resources
  43724. * @param onProgress The callback when the load progresses
  43725. * @param fileName Defines the name of the file to load
  43726. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43727. */
  43728. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43729. meshes: AbstractMesh[];
  43730. particleSystems: IParticleSystem[];
  43731. skeletons: Skeleton[];
  43732. animationGroups: AnimationGroup[];
  43733. }>;
  43734. /**
  43735. * Load into a scene.
  43736. * @param scene The scene to load into
  43737. * @param data The data to import
  43738. * @param rootUrl The root url for scene and resources
  43739. * @param onProgress The callback when the load progresses
  43740. * @param fileName Defines the name of the file to load
  43741. * @returns Nothing
  43742. */
  43743. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43744. /**
  43745. * Load into an asset container.
  43746. * @param scene The scene to load into
  43747. * @param data The data to import
  43748. * @param rootUrl The root url for scene and resources
  43749. * @param onProgress The callback when the load progresses
  43750. * @param fileName Defines the name of the file to load
  43751. * @returns The loaded asset container
  43752. */
  43753. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43754. }
  43755. /**
  43756. * Mode that determines how to handle old animation groups before loading new ones.
  43757. */
  43758. export enum SceneLoaderAnimationGroupLoadingMode {
  43759. /**
  43760. * Reset all old animations to initial state then dispose them.
  43761. */
  43762. Clean = 0,
  43763. /**
  43764. * Stop all old animations.
  43765. */
  43766. Stop = 1,
  43767. /**
  43768. * Restart old animations from first frame.
  43769. */
  43770. Sync = 2,
  43771. /**
  43772. * Old animations remains untouched.
  43773. */
  43774. NoSync = 3
  43775. }
  43776. /**
  43777. * Class used to load scene from various file formats using registered plugins
  43778. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43779. */
  43780. export class SceneLoader {
  43781. /**
  43782. * No logging while loading
  43783. */
  43784. static readonly NO_LOGGING: number;
  43785. /**
  43786. * Minimal logging while loading
  43787. */
  43788. static readonly MINIMAL_LOGGING: number;
  43789. /**
  43790. * Summary logging while loading
  43791. */
  43792. static readonly SUMMARY_LOGGING: number;
  43793. /**
  43794. * Detailled logging while loading
  43795. */
  43796. static readonly DETAILED_LOGGING: number;
  43797. /**
  43798. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43799. */
  43800. static get ForceFullSceneLoadingForIncremental(): boolean;
  43801. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43802. /**
  43803. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43804. */
  43805. static get ShowLoadingScreen(): boolean;
  43806. static set ShowLoadingScreen(value: boolean);
  43807. /**
  43808. * Defines the current logging level (while loading the scene)
  43809. * @ignorenaming
  43810. */
  43811. static get loggingLevel(): number;
  43812. static set loggingLevel(value: number);
  43813. /**
  43814. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43815. */
  43816. static get CleanBoneMatrixWeights(): boolean;
  43817. static set CleanBoneMatrixWeights(value: boolean);
  43818. /**
  43819. * Event raised when a plugin is used to load a scene
  43820. */
  43821. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43822. private static _registeredPlugins;
  43823. private static _getDefaultPlugin;
  43824. private static _getPluginForExtension;
  43825. private static _getPluginForDirectLoad;
  43826. private static _getPluginForFilename;
  43827. private static _getDirectLoad;
  43828. private static _loadData;
  43829. private static _getFileInfo;
  43830. /**
  43831. * Gets a plugin that can load the given extension
  43832. * @param extension defines the extension to load
  43833. * @returns a plugin or null if none works
  43834. */
  43835. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43836. /**
  43837. * Gets a boolean indicating that the given extension can be loaded
  43838. * @param extension defines the extension to load
  43839. * @returns true if the extension is supported
  43840. */
  43841. static IsPluginForExtensionAvailable(extension: string): boolean;
  43842. /**
  43843. * Adds a new plugin to the list of registered plugins
  43844. * @param plugin defines the plugin to add
  43845. */
  43846. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43847. /**
  43848. * Import meshes into a scene
  43849. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43850. * @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)
  43851. * @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)
  43852. * @param scene the instance of BABYLON.Scene to append to
  43853. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43854. * @param onProgress a callback with a progress event for each file being loaded
  43855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43856. * @param pluginExtension the extension used to determine the plugin
  43857. * @returns The loaded plugin
  43858. */
  43859. 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>;
  43860. /**
  43861. * Import meshes into a scene
  43862. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43863. * @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)
  43864. * @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)
  43865. * @param scene the instance of BABYLON.Scene to append to
  43866. * @param onProgress a callback with a progress event for each file being loaded
  43867. * @param pluginExtension the extension used to determine the plugin
  43868. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43869. */
  43870. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43871. meshes: AbstractMesh[];
  43872. particleSystems: IParticleSystem[];
  43873. skeletons: Skeleton[];
  43874. animationGroups: AnimationGroup[];
  43875. }>;
  43876. /**
  43877. * Load a scene
  43878. * @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)
  43879. * @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)
  43880. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43881. * @param onSuccess a callback with the scene when import succeeds
  43882. * @param onProgress a callback with a progress event for each file being loaded
  43883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43884. * @param pluginExtension the extension used to determine the plugin
  43885. * @returns The loaded plugin
  43886. */
  43887. 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>;
  43888. /**
  43889. * Load a scene
  43890. * @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)
  43891. * @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)
  43892. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43893. * @param onProgress a callback with a progress event for each file being loaded
  43894. * @param pluginExtension the extension used to determine the plugin
  43895. * @returns The loaded scene
  43896. */
  43897. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43898. /**
  43899. * Append a scene
  43900. * @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)
  43901. * @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)
  43902. * @param scene is the instance of BABYLON.Scene to append to
  43903. * @param onSuccess a callback with the scene when import succeeds
  43904. * @param onProgress a callback with a progress event for each file being loaded
  43905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43906. * @param pluginExtension the extension used to determine the plugin
  43907. * @returns The loaded plugin
  43908. */
  43909. 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>;
  43910. /**
  43911. * Append a scene
  43912. * @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)
  43913. * @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)
  43914. * @param scene is the instance of BABYLON.Scene to append to
  43915. * @param onProgress a callback with a progress event for each file being loaded
  43916. * @param pluginExtension the extension used to determine the plugin
  43917. * @returns The given scene
  43918. */
  43919. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43920. /**
  43921. * Load a scene into an asset container
  43922. * @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)
  43923. * @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)
  43924. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43925. * @param onSuccess a callback with the scene when import succeeds
  43926. * @param onProgress a callback with a progress event for each file being loaded
  43927. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43928. * @param pluginExtension the extension used to determine the plugin
  43929. * @returns The loaded plugin
  43930. */
  43931. 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>;
  43932. /**
  43933. * Load a scene into an asset container
  43934. * @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)
  43935. * @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)
  43936. * @param scene is the instance of Scene to append to
  43937. * @param onProgress a callback with a progress event for each file being loaded
  43938. * @param pluginExtension the extension used to determine the plugin
  43939. * @returns The loaded asset container
  43940. */
  43941. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43942. /**
  43943. * Import animations from a file into a scene
  43944. * @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)
  43945. * @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)
  43946. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43947. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43948. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43949. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43950. * @param onSuccess a callback with the scene when import succeeds
  43951. * @param onProgress a callback with a progress event for each file being loaded
  43952. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43953. */
  43954. 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;
  43955. /**
  43956. * Import animations from a file into a scene
  43957. * @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)
  43958. * @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)
  43959. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43960. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43961. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43962. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43963. * @param onSuccess a callback with the scene when import succeeds
  43964. * @param onProgress a callback with a progress event for each file being loaded
  43965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43966. * @returns the updated scene with imported animations
  43967. */
  43968. 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>;
  43969. }
  43970. }
  43971. declare module BABYLON {
  43972. /**
  43973. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43974. */
  43975. export type MotionControllerHandness = "none" | "left" | "right";
  43976. /**
  43977. * The type of components available in motion controllers.
  43978. * This is not the name of the component.
  43979. */
  43980. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43981. /**
  43982. * The state of a controller component
  43983. */
  43984. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43985. /**
  43986. * The schema of motion controller layout.
  43987. * No object will be initialized using this interface
  43988. * This is used just to define the profile.
  43989. */
  43990. export interface IMotionControllerLayout {
  43991. /**
  43992. * Path to load the assets. Usually relative to the base path
  43993. */
  43994. assetPath: string;
  43995. /**
  43996. * Available components (unsorted)
  43997. */
  43998. components: {
  43999. /**
  44000. * A map of component Ids
  44001. */
  44002. [componentId: string]: {
  44003. /**
  44004. * The type of input the component outputs
  44005. */
  44006. type: MotionControllerComponentType;
  44007. /**
  44008. * The indices of this component in the gamepad object
  44009. */
  44010. gamepadIndices: {
  44011. /**
  44012. * Index of button
  44013. */
  44014. button?: number;
  44015. /**
  44016. * If available, index of x-axis
  44017. */
  44018. xAxis?: number;
  44019. /**
  44020. * If available, index of y-axis
  44021. */
  44022. yAxis?: number;
  44023. };
  44024. /**
  44025. * The mesh's root node name
  44026. */
  44027. rootNodeName: string;
  44028. /**
  44029. * Animation definitions for this model
  44030. */
  44031. visualResponses: {
  44032. [stateKey: string]: {
  44033. /**
  44034. * What property will be animated
  44035. */
  44036. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44037. /**
  44038. * What states influence this visual response
  44039. */
  44040. states: MotionControllerComponentStateType[];
  44041. /**
  44042. * Type of animation - movement or visibility
  44043. */
  44044. valueNodeProperty: "transform" | "visibility";
  44045. /**
  44046. * Base node name to move. Its position will be calculated according to the min and max nodes
  44047. */
  44048. valueNodeName?: string;
  44049. /**
  44050. * Minimum movement node
  44051. */
  44052. minNodeName?: string;
  44053. /**
  44054. * Max movement node
  44055. */
  44056. maxNodeName?: string;
  44057. };
  44058. };
  44059. /**
  44060. * If touch enabled, what is the name of node to display user feedback
  44061. */
  44062. touchPointNodeName?: string;
  44063. };
  44064. };
  44065. /**
  44066. * Is it xr standard mapping or not
  44067. */
  44068. gamepadMapping: "" | "xr-standard";
  44069. /**
  44070. * Base root node of this entire model
  44071. */
  44072. rootNodeName: string;
  44073. /**
  44074. * Defines the main button component id
  44075. */
  44076. selectComponentId: string;
  44077. }
  44078. /**
  44079. * A definition for the layout map in the input profile
  44080. */
  44081. export interface IMotionControllerLayoutMap {
  44082. /**
  44083. * Layouts with handness type as a key
  44084. */
  44085. [handness: string]: IMotionControllerLayout;
  44086. }
  44087. /**
  44088. * The XR Input profile schema
  44089. * Profiles can be found here:
  44090. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44091. */
  44092. export interface IMotionControllerProfile {
  44093. /**
  44094. * fallback profiles for this profileId
  44095. */
  44096. fallbackProfileIds: string[];
  44097. /**
  44098. * The layout map, with handness as key
  44099. */
  44100. layouts: IMotionControllerLayoutMap;
  44101. /**
  44102. * The id of this profile
  44103. * correlates to the profile(s) in the xrInput.profiles array
  44104. */
  44105. profileId: string;
  44106. }
  44107. /**
  44108. * A helper-interface for the 3 meshes needed for controller button animation
  44109. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44110. */
  44111. export interface IMotionControllerButtonMeshMap {
  44112. /**
  44113. * the mesh that defines the pressed value mesh position.
  44114. * This is used to find the max-position of this button
  44115. */
  44116. pressedMesh: AbstractMesh;
  44117. /**
  44118. * the mesh that defines the unpressed value mesh position.
  44119. * This is used to find the min (or initial) position of this button
  44120. */
  44121. unpressedMesh: AbstractMesh;
  44122. /**
  44123. * The mesh that will be changed when value changes
  44124. */
  44125. valueMesh: AbstractMesh;
  44126. }
  44127. /**
  44128. * A helper-interface for the 3 meshes needed for controller axis animation.
  44129. * This will be expanded when touchpad animations are fully supported
  44130. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44131. */
  44132. export interface IMotionControllerMeshMap {
  44133. /**
  44134. * the mesh that defines the maximum value mesh position.
  44135. */
  44136. maxMesh?: AbstractMesh;
  44137. /**
  44138. * the mesh that defines the minimum value mesh position.
  44139. */
  44140. minMesh?: AbstractMesh;
  44141. /**
  44142. * The mesh that will be changed when axis value changes
  44143. */
  44144. valueMesh: AbstractMesh;
  44145. }
  44146. /**
  44147. * The elements needed for change-detection of the gamepad objects in motion controllers
  44148. */
  44149. export interface IMinimalMotionControllerObject {
  44150. /**
  44151. * Available axes of this controller
  44152. */
  44153. axes: number[];
  44154. /**
  44155. * An array of available buttons
  44156. */
  44157. buttons: Array<{
  44158. /**
  44159. * Value of the button/trigger
  44160. */
  44161. value: number;
  44162. /**
  44163. * If the button/trigger is currently touched
  44164. */
  44165. touched: boolean;
  44166. /**
  44167. * If the button/trigger is currently pressed
  44168. */
  44169. pressed: boolean;
  44170. }>;
  44171. }
  44172. /**
  44173. * An Abstract Motion controller
  44174. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44175. * Each component has an observable to check for changes in value and state
  44176. */
  44177. export abstract class WebXRAbstractMotionController implements IDisposable {
  44178. protected scene: Scene;
  44179. protected layout: IMotionControllerLayout;
  44180. /**
  44181. * The gamepad object correlating to this controller
  44182. */
  44183. gamepadObject: IMinimalMotionControllerObject;
  44184. /**
  44185. * handness (left/right/none) of this controller
  44186. */
  44187. handness: MotionControllerHandness;
  44188. private _initComponent;
  44189. private _modelReady;
  44190. /**
  44191. * A map of components (WebXRControllerComponent) in this motion controller
  44192. * Components have a ComponentType and can also have both button and axis definitions
  44193. */
  44194. readonly components: {
  44195. [id: string]: WebXRControllerComponent;
  44196. };
  44197. /**
  44198. * Disable the model's animation. Can be set at any time.
  44199. */
  44200. disableAnimation: boolean;
  44201. /**
  44202. * Observers registered here will be triggered when the model of this controller is done loading
  44203. */
  44204. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44205. /**
  44206. * The profile id of this motion controller
  44207. */
  44208. abstract profileId: string;
  44209. /**
  44210. * The root mesh of the model. It is null if the model was not yet initialized
  44211. */
  44212. rootMesh: Nullable<AbstractMesh>;
  44213. /**
  44214. * constructs a new abstract motion controller
  44215. * @param scene the scene to which the model of the controller will be added
  44216. * @param layout The profile layout to load
  44217. * @param gamepadObject The gamepad object correlating to this controller
  44218. * @param handness handness (left/right/none) of this controller
  44219. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44220. */
  44221. constructor(scene: Scene, layout: IMotionControllerLayout,
  44222. /**
  44223. * The gamepad object correlating to this controller
  44224. */
  44225. gamepadObject: IMinimalMotionControllerObject,
  44226. /**
  44227. * handness (left/right/none) of this controller
  44228. */
  44229. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44230. /**
  44231. * Dispose this controller, the model mesh and all its components
  44232. */
  44233. dispose(): void;
  44234. /**
  44235. * Returns all components of specific type
  44236. * @param type the type to search for
  44237. * @return an array of components with this type
  44238. */
  44239. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44240. /**
  44241. * get a component based an its component id as defined in layout.components
  44242. * @param id the id of the component
  44243. * @returns the component correlates to the id or undefined if not found
  44244. */
  44245. getComponent(id: string): WebXRControllerComponent;
  44246. /**
  44247. * Get the list of components available in this motion controller
  44248. * @returns an array of strings correlating to available components
  44249. */
  44250. getComponentIds(): string[];
  44251. /**
  44252. * Get the first component of specific type
  44253. * @param type type of component to find
  44254. * @return a controller component or null if not found
  44255. */
  44256. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44257. /**
  44258. * Get the main (Select) component of this controller as defined in the layout
  44259. * @returns the main component of this controller
  44260. */
  44261. getMainComponent(): WebXRControllerComponent;
  44262. /**
  44263. * Loads the model correlating to this controller
  44264. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44265. * @returns A promise fulfilled with the result of the model loading
  44266. */
  44267. loadModel(): Promise<boolean>;
  44268. /**
  44269. * Update this model using the current XRFrame
  44270. * @param xrFrame the current xr frame to use and update the model
  44271. */
  44272. updateFromXRFrame(xrFrame: XRFrame): void;
  44273. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44274. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44275. /**
  44276. * Moves the axis on the controller mesh based on its current state
  44277. * @param axis the index of the axis
  44278. * @param axisValue the value of the axis which determines the meshes new position
  44279. * @hidden
  44280. */
  44281. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44282. /**
  44283. * Update the model itself with the current frame data
  44284. * @param xrFrame the frame to use for updating the model mesh
  44285. */
  44286. protected updateModel(xrFrame: XRFrame): void;
  44287. /**
  44288. * Get the filename and path for this controller's model
  44289. * @returns a map of filename and path
  44290. */
  44291. protected abstract _getFilenameAndPath(): {
  44292. filename: string;
  44293. path: string;
  44294. };
  44295. /**
  44296. * This function is called before the mesh is loaded. It checks for loading constraints.
  44297. * For example, this function can check if the GLB loader is available
  44298. * If this function returns false, the generic controller will be loaded instead
  44299. * @returns Is the client ready to load the mesh
  44300. */
  44301. protected abstract _getModelLoadingConstraints(): boolean;
  44302. /**
  44303. * This function will be called after the model was successfully loaded and can be used
  44304. * for mesh transformations before it is available for the user
  44305. * @param meshes the loaded meshes
  44306. */
  44307. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44308. /**
  44309. * Set the root mesh for this controller. Important for the WebXR controller class
  44310. * @param meshes the loaded meshes
  44311. */
  44312. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44313. /**
  44314. * A function executed each frame that updates the mesh (if needed)
  44315. * @param xrFrame the current xrFrame
  44316. */
  44317. protected abstract _updateModel(xrFrame: XRFrame): void;
  44318. private _getGenericFilenameAndPath;
  44319. private _getGenericParentMesh;
  44320. }
  44321. }
  44322. declare module BABYLON {
  44323. /**
  44324. * A generic trigger-only motion controller for WebXR
  44325. */
  44326. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44327. /**
  44328. * Static version of the profile id of this controller
  44329. */
  44330. static ProfileId: string;
  44331. profileId: string;
  44332. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44333. protected _getFilenameAndPath(): {
  44334. filename: string;
  44335. path: string;
  44336. };
  44337. protected _getModelLoadingConstraints(): boolean;
  44338. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44339. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44340. protected _updateModel(): void;
  44341. }
  44342. }
  44343. declare module BABYLON {
  44344. /**
  44345. * Class containing static functions to help procedurally build meshes
  44346. */
  44347. export class SphereBuilder {
  44348. /**
  44349. * Creates a sphere mesh
  44350. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44351. * * 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`)
  44352. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44353. * * 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
  44354. * * 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)
  44355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44356. * * 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
  44357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44358. * @param name defines the name of the mesh
  44359. * @param options defines the options used to create the mesh
  44360. * @param scene defines the hosting scene
  44361. * @returns the sphere mesh
  44362. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44363. */
  44364. static CreateSphere(name: string, options: {
  44365. segments?: number;
  44366. diameter?: number;
  44367. diameterX?: number;
  44368. diameterY?: number;
  44369. diameterZ?: number;
  44370. arc?: number;
  44371. slice?: number;
  44372. sideOrientation?: number;
  44373. frontUVs?: Vector4;
  44374. backUVs?: Vector4;
  44375. updatable?: boolean;
  44376. }, scene?: Nullable<Scene>): Mesh;
  44377. }
  44378. }
  44379. declare module BABYLON {
  44380. /**
  44381. * A profiled motion controller has its profile loaded from an online repository.
  44382. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44383. */
  44384. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44385. private _repositoryUrl;
  44386. private _buttonMeshMapping;
  44387. private _touchDots;
  44388. /**
  44389. * The profile ID of this controller. Will be populated when the controller initializes.
  44390. */
  44391. profileId: string;
  44392. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44393. dispose(): void;
  44394. protected _getFilenameAndPath(): {
  44395. filename: string;
  44396. path: string;
  44397. };
  44398. protected _getModelLoadingConstraints(): boolean;
  44399. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44400. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44401. protected _updateModel(_xrFrame: XRFrame): void;
  44402. }
  44403. }
  44404. declare module BABYLON {
  44405. /**
  44406. * A construction function type to create a new controller based on an xrInput object
  44407. */
  44408. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44409. /**
  44410. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44411. *
  44412. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44413. * it should be replaced with auto-loaded controllers.
  44414. *
  44415. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44416. */
  44417. export class WebXRMotionControllerManager {
  44418. private static _AvailableControllers;
  44419. private static _Fallbacks;
  44420. private static _ProfileLoadingPromises;
  44421. private static _ProfilesList;
  44422. /**
  44423. * The base URL of the online controller repository. Can be changed at any time.
  44424. */
  44425. static BaseRepositoryUrl: string;
  44426. /**
  44427. * Which repository gets priority - local or online
  44428. */
  44429. static PrioritizeOnlineRepository: boolean;
  44430. /**
  44431. * Use the online repository, or use only locally-defined controllers
  44432. */
  44433. static UseOnlineRepository: boolean;
  44434. /**
  44435. * Clear the cache used for profile loading and reload when requested again
  44436. */
  44437. static ClearProfilesCache(): void;
  44438. /**
  44439. * Register the default fallbacks.
  44440. * This function is called automatically when this file is imported.
  44441. */
  44442. static DefaultFallbacks(): void;
  44443. /**
  44444. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44445. * @param profileId the profile to which a fallback needs to be found
  44446. * @return an array with corresponding fallback profiles
  44447. */
  44448. static FindFallbackWithProfileId(profileId: string): string[];
  44449. /**
  44450. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44451. * The order of search:
  44452. *
  44453. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44454. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44455. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44456. * 4) return the generic trigger controller if none were found
  44457. *
  44458. * @param xrInput the xrInput to which a new controller is initialized
  44459. * @param scene the scene to which the model will be added
  44460. * @param forceProfile force a certain profile for this controller
  44461. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44462. */
  44463. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44464. /**
  44465. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44466. *
  44467. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44468. *
  44469. * @param type the profile type to register
  44470. * @param constructFunction the function to be called when loading this profile
  44471. */
  44472. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44473. /**
  44474. * Register a fallback to a specific profile.
  44475. * @param profileId the profileId that will receive the fallbacks
  44476. * @param fallbacks A list of fallback profiles
  44477. */
  44478. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44479. /**
  44480. * Will update the list of profiles available in the repository
  44481. * @return a promise that resolves to a map of profiles available online
  44482. */
  44483. static UpdateProfilesList(): Promise<{
  44484. [profile: string]: string;
  44485. }>;
  44486. private static _LoadProfileFromRepository;
  44487. private static _LoadProfilesFromAvailableControllers;
  44488. }
  44489. }
  44490. declare module BABYLON {
  44491. /**
  44492. * Configuration options for the WebXR controller creation
  44493. */
  44494. export interface IWebXRControllerOptions {
  44495. /**
  44496. * Should the controller mesh be animated when a user interacts with it
  44497. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44498. */
  44499. disableMotionControllerAnimation?: boolean;
  44500. /**
  44501. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44502. */
  44503. doNotLoadControllerMesh?: boolean;
  44504. /**
  44505. * Force a specific controller type for this controller.
  44506. * This can be used when creating your own profile or when testing different controllers
  44507. */
  44508. forceControllerProfile?: string;
  44509. }
  44510. /**
  44511. * Represents an XR controller
  44512. */
  44513. export class WebXRInputSource {
  44514. private _scene;
  44515. /** The underlying input source for the controller */
  44516. inputSource: XRInputSource;
  44517. private _options;
  44518. private _tmpQuaternion;
  44519. private _tmpVector;
  44520. private _uniqueId;
  44521. /**
  44522. * 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
  44523. */
  44524. grip?: AbstractMesh;
  44525. /**
  44526. * If available, this is the gamepad object related to this controller.
  44527. * Using this object it is possible to get click events and trackpad changes of the
  44528. * webxr controller that is currently being used.
  44529. */
  44530. motionController?: WebXRAbstractMotionController;
  44531. /**
  44532. * Event that fires when the controller is removed/disposed.
  44533. * The object provided as event data is this controller, after associated assets were disposed.
  44534. * uniqueId is still available.
  44535. */
  44536. onDisposeObservable: Observable<WebXRInputSource>;
  44537. /**
  44538. * Will be triggered when the mesh associated with the motion controller is done loading.
  44539. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44540. * A shortened version of controller -> motion controller -> on mesh loaded.
  44541. */
  44542. onMeshLoadedObservable: Observable<AbstractMesh>;
  44543. /**
  44544. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44545. */
  44546. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44547. /**
  44548. * Pointer which can be used to select objects or attach a visible laser to
  44549. */
  44550. pointer: AbstractMesh;
  44551. /**
  44552. * Creates the controller
  44553. * @see https://doc.babylonjs.com/how_to/webxr
  44554. * @param _scene the scene which the controller should be associated to
  44555. * @param inputSource the underlying input source for the controller
  44556. * @param _options options for this controller creation
  44557. */
  44558. constructor(_scene: Scene,
  44559. /** The underlying input source for the controller */
  44560. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44561. /**
  44562. * Get this controllers unique id
  44563. */
  44564. get uniqueId(): string;
  44565. /**
  44566. * Disposes of the object
  44567. */
  44568. dispose(): void;
  44569. /**
  44570. * Gets a world space ray coming from the pointer or grip
  44571. * @param result the resulting ray
  44572. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44573. */
  44574. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44575. /**
  44576. * Updates the controller pose based on the given XRFrame
  44577. * @param xrFrame xr frame to update the pose with
  44578. * @param referenceSpace reference space to use
  44579. */
  44580. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44581. }
  44582. }
  44583. declare module BABYLON {
  44584. /**
  44585. * The schema for initialization options of the XR Input class
  44586. */
  44587. export interface IWebXRInputOptions {
  44588. /**
  44589. * If set to true no model will be automatically loaded
  44590. */
  44591. doNotLoadControllerMeshes?: boolean;
  44592. /**
  44593. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44594. * If not found, the xr input profile data will be used.
  44595. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44596. */
  44597. forceInputProfile?: string;
  44598. /**
  44599. * Do not send a request to the controller repository to load the profile.
  44600. *
  44601. * Instead, use the controllers available in babylon itself.
  44602. */
  44603. disableOnlineControllerRepository?: boolean;
  44604. /**
  44605. * A custom URL for the controllers repository
  44606. */
  44607. customControllersRepositoryURL?: string;
  44608. /**
  44609. * Should the controller model's components not move according to the user input
  44610. */
  44611. disableControllerAnimation?: boolean;
  44612. }
  44613. /**
  44614. * XR input used to track XR inputs such as controllers/rays
  44615. */
  44616. export class WebXRInput implements IDisposable {
  44617. /**
  44618. * the xr session manager for this session
  44619. */
  44620. xrSessionManager: WebXRSessionManager;
  44621. /**
  44622. * the WebXR camera for this session. Mainly used for teleportation
  44623. */
  44624. xrCamera: WebXRCamera;
  44625. private readonly options;
  44626. /**
  44627. * XR controllers being tracked
  44628. */
  44629. controllers: Array<WebXRInputSource>;
  44630. private _frameObserver;
  44631. private _sessionEndedObserver;
  44632. private _sessionInitObserver;
  44633. /**
  44634. * Event when a controller has been connected/added
  44635. */
  44636. onControllerAddedObservable: Observable<WebXRInputSource>;
  44637. /**
  44638. * Event when a controller has been removed/disconnected
  44639. */
  44640. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44641. /**
  44642. * Initializes the WebXRInput
  44643. * @param xrSessionManager the xr session manager for this session
  44644. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44645. * @param options = initialization options for this xr input
  44646. */
  44647. constructor(
  44648. /**
  44649. * the xr session manager for this session
  44650. */
  44651. xrSessionManager: WebXRSessionManager,
  44652. /**
  44653. * the WebXR camera for this session. Mainly used for teleportation
  44654. */
  44655. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44656. private _onInputSourcesChange;
  44657. private _addAndRemoveControllers;
  44658. /**
  44659. * Disposes of the object
  44660. */
  44661. dispose(): void;
  44662. }
  44663. }
  44664. declare module BABYLON {
  44665. /**
  44666. * This is the base class for all WebXR features.
  44667. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44668. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44669. */
  44670. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44671. protected _xrSessionManager: WebXRSessionManager;
  44672. private _attached;
  44673. private _removeOnDetach;
  44674. /**
  44675. * Should auto-attach be disabled?
  44676. */
  44677. disableAutoAttach: boolean;
  44678. /**
  44679. * Construct a new (abstract) WebXR feature
  44680. * @param _xrSessionManager the xr session manager for this feature
  44681. */
  44682. constructor(_xrSessionManager: WebXRSessionManager);
  44683. /**
  44684. * Is this feature attached
  44685. */
  44686. get attached(): boolean;
  44687. /**
  44688. * attach this feature
  44689. *
  44690. * @param force should attachment be forced (even when already attached)
  44691. * @returns true if successful, false is failed or already attached
  44692. */
  44693. attach(force?: boolean): boolean;
  44694. /**
  44695. * detach this feature.
  44696. *
  44697. * @returns true if successful, false if failed or already detached
  44698. */
  44699. detach(): boolean;
  44700. /**
  44701. * Dispose this feature and all of the resources attached
  44702. */
  44703. dispose(): void;
  44704. /**
  44705. * This is used to register callbacks that will automatically be removed when detach is called.
  44706. * @param observable the observable to which the observer will be attached
  44707. * @param callback the callback to register
  44708. */
  44709. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44710. /**
  44711. * Code in this function will be executed on each xrFrame received from the browser.
  44712. * This function will not execute after the feature is detached.
  44713. * @param _xrFrame the current frame
  44714. */
  44715. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44716. }
  44717. }
  44718. declare module BABYLON {
  44719. /**
  44720. * Renders a layer on top of an existing scene
  44721. */
  44722. export class UtilityLayerRenderer implements IDisposable {
  44723. /** the original scene that will be rendered on top of */
  44724. originalScene: Scene;
  44725. private _pointerCaptures;
  44726. private _lastPointerEvents;
  44727. private static _DefaultUtilityLayer;
  44728. private static _DefaultKeepDepthUtilityLayer;
  44729. private _sharedGizmoLight;
  44730. private _renderCamera;
  44731. /**
  44732. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44733. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44734. * @returns the camera that is used when rendering the utility layer
  44735. */
  44736. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44737. /**
  44738. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44739. * @param cam the camera that should be used when rendering the utility layer
  44740. */
  44741. setRenderCamera(cam: Nullable<Camera>): void;
  44742. /**
  44743. * @hidden
  44744. * Light which used by gizmos to get light shading
  44745. */
  44746. _getSharedGizmoLight(): HemisphericLight;
  44747. /**
  44748. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44749. */
  44750. pickUtilitySceneFirst: boolean;
  44751. /**
  44752. * 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)
  44753. */
  44754. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44755. /**
  44756. * 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)
  44757. */
  44758. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44759. /**
  44760. * The scene that is rendered on top of the original scene
  44761. */
  44762. utilityLayerScene: Scene;
  44763. /**
  44764. * If the utility layer should automatically be rendered on top of existing scene
  44765. */
  44766. shouldRender: boolean;
  44767. /**
  44768. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44769. */
  44770. onlyCheckPointerDownEvents: boolean;
  44771. /**
  44772. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44773. */
  44774. processAllEvents: boolean;
  44775. /**
  44776. * Observable raised when the pointer move from the utility layer scene to the main scene
  44777. */
  44778. onPointerOutObservable: Observable<number>;
  44779. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44780. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44781. private _afterRenderObserver;
  44782. private _sceneDisposeObserver;
  44783. private _originalPointerObserver;
  44784. /**
  44785. * Instantiates a UtilityLayerRenderer
  44786. * @param originalScene the original scene that will be rendered on top of
  44787. * @param handleEvents boolean indicating if the utility layer should handle events
  44788. */
  44789. constructor(
  44790. /** the original scene that will be rendered on top of */
  44791. originalScene: Scene, handleEvents?: boolean);
  44792. private _notifyObservers;
  44793. /**
  44794. * Renders the utility layers scene on top of the original scene
  44795. */
  44796. render(): void;
  44797. /**
  44798. * Disposes of the renderer
  44799. */
  44800. dispose(): void;
  44801. private _updateCamera;
  44802. }
  44803. }
  44804. declare module BABYLON {
  44805. /**
  44806. * Options interface for the pointer selection module
  44807. */
  44808. export interface IWebXRControllerPointerSelectionOptions {
  44809. /**
  44810. * if provided, this scene will be used to render meshes.
  44811. */
  44812. customUtilityLayerScene?: Scene;
  44813. /**
  44814. * 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)
  44815. * If not disabled, the last picked point will be used to execute a pointer up event
  44816. * If disabled, pointer up event will be triggered right after the pointer down event.
  44817. * Used in screen and gaze target ray mode only
  44818. */
  44819. disablePointerUpOnTouchOut: boolean;
  44820. /**
  44821. * For gaze mode (time to select instead of press)
  44822. */
  44823. forceGazeMode: boolean;
  44824. /**
  44825. * 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
  44826. * to start a new countdown to the pointer down event.
  44827. * Defaults to 1.
  44828. */
  44829. gazeModePointerMovedFactor?: number;
  44830. /**
  44831. * Different button type to use instead of the main component
  44832. */
  44833. overrideButtonId?: string;
  44834. /**
  44835. * use this rendering group id for the meshes (optional)
  44836. */
  44837. renderingGroupId?: number;
  44838. /**
  44839. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44840. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44841. * 3000 means 3 seconds between pointing at something and selecting it
  44842. */
  44843. timeToSelect?: number;
  44844. /**
  44845. * Should meshes created here be added to a utility layer or the main scene
  44846. */
  44847. useUtilityLayer?: boolean;
  44848. /**
  44849. * the xr input to use with this pointer selection
  44850. */
  44851. xrInput: WebXRInput;
  44852. }
  44853. /**
  44854. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44855. */
  44856. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44857. private readonly _options;
  44858. private static _idCounter;
  44859. private _attachController;
  44860. private _controllers;
  44861. private _scene;
  44862. private _tmpVectorForPickCompare;
  44863. /**
  44864. * The module's name
  44865. */
  44866. static readonly Name: string;
  44867. /**
  44868. * The (Babylon) version of this module.
  44869. * This is an integer representing the implementation version.
  44870. * This number does not correspond to the WebXR specs version
  44871. */
  44872. static readonly Version: number;
  44873. /**
  44874. * Disable lighting on the laser pointer (so it will always be visible)
  44875. */
  44876. disablePointerLighting: boolean;
  44877. /**
  44878. * Disable lighting on the selection mesh (so it will always be visible)
  44879. */
  44880. disableSelectionMeshLighting: boolean;
  44881. /**
  44882. * Should the laser pointer be displayed
  44883. */
  44884. displayLaserPointer: boolean;
  44885. /**
  44886. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44887. */
  44888. displaySelectionMesh: boolean;
  44889. /**
  44890. * This color will be set to the laser pointer when selection is triggered
  44891. */
  44892. laserPointerPickedColor: Color3;
  44893. /**
  44894. * Default color of the laser pointer
  44895. */
  44896. lasterPointerDefaultColor: Color3;
  44897. /**
  44898. * default color of the selection ring
  44899. */
  44900. selectionMeshDefaultColor: Color3;
  44901. /**
  44902. * This color will be applied to the selection ring when selection is triggered
  44903. */
  44904. selectionMeshPickedColor: Color3;
  44905. /**
  44906. * Optional filter to be used for ray selection. This predicate shares behavior with
  44907. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44908. */
  44909. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44910. /**
  44911. * constructs a new background remover module
  44912. * @param _xrSessionManager the session manager for this module
  44913. * @param _options read-only options to be used in this module
  44914. */
  44915. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44916. /**
  44917. * attach this feature
  44918. * Will usually be called by the features manager
  44919. *
  44920. * @returns true if successful.
  44921. */
  44922. attach(): boolean;
  44923. /**
  44924. * detach this feature.
  44925. * Will usually be called by the features manager
  44926. *
  44927. * @returns true if successful.
  44928. */
  44929. detach(): boolean;
  44930. /**
  44931. * Will get the mesh under a specific pointer.
  44932. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44933. * @param controllerId the controllerId to check
  44934. * @returns The mesh under pointer or null if no mesh is under the pointer
  44935. */
  44936. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44937. /**
  44938. * Get the xr controller that correlates to the pointer id in the pointer event
  44939. *
  44940. * @param id the pointer id to search for
  44941. * @returns the controller that correlates to this id or null if not found
  44942. */
  44943. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44944. protected _onXRFrame(_xrFrame: XRFrame): void;
  44945. private _attachGazeMode;
  44946. private _attachScreenRayMode;
  44947. private _attachTrackedPointerRayMode;
  44948. private _convertNormalToDirectionOfRay;
  44949. private _detachController;
  44950. private _generateNewMeshPair;
  44951. private _pickingMoved;
  44952. private _updatePointerDistance;
  44953. }
  44954. }
  44955. declare module BABYLON {
  44956. /**
  44957. * Button which can be used to enter a different mode of XR
  44958. */
  44959. export class WebXREnterExitUIButton {
  44960. /** button element */
  44961. element: HTMLElement;
  44962. /** XR initialization options for the button */
  44963. sessionMode: XRSessionMode;
  44964. /** Reference space type */
  44965. referenceSpaceType: XRReferenceSpaceType;
  44966. /**
  44967. * Creates a WebXREnterExitUIButton
  44968. * @param element button element
  44969. * @param sessionMode XR initialization session mode
  44970. * @param referenceSpaceType the type of reference space to be used
  44971. */
  44972. constructor(
  44973. /** button element */
  44974. element: HTMLElement,
  44975. /** XR initialization options for the button */
  44976. sessionMode: XRSessionMode,
  44977. /** Reference space type */
  44978. referenceSpaceType: XRReferenceSpaceType);
  44979. /**
  44980. * Extendable function which can be used to update the button's visuals when the state changes
  44981. * @param activeButton the current active button in the UI
  44982. */
  44983. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44984. }
  44985. /**
  44986. * Options to create the webXR UI
  44987. */
  44988. export class WebXREnterExitUIOptions {
  44989. /**
  44990. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44991. */
  44992. customButtons?: Array<WebXREnterExitUIButton>;
  44993. /**
  44994. * A reference space type to use when creating the default button.
  44995. * Default is local-floor
  44996. */
  44997. referenceSpaceType?: XRReferenceSpaceType;
  44998. /**
  44999. * Context to enter xr with
  45000. */
  45001. renderTarget?: Nullable<WebXRRenderTarget>;
  45002. /**
  45003. * A session mode to use when creating the default button.
  45004. * Default is immersive-vr
  45005. */
  45006. sessionMode?: XRSessionMode;
  45007. }
  45008. /**
  45009. * UI to allow the user to enter/exit XR mode
  45010. */
  45011. export class WebXREnterExitUI implements IDisposable {
  45012. private scene;
  45013. /** version of the options passed to this UI */
  45014. options: WebXREnterExitUIOptions;
  45015. private _activeButton;
  45016. private _buttons;
  45017. private _overlay;
  45018. /**
  45019. * Fired every time the active button is changed.
  45020. *
  45021. * When xr is entered via a button that launches xr that button will be the callback parameter
  45022. *
  45023. * When exiting xr the callback parameter will be null)
  45024. */
  45025. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45026. /**
  45027. *
  45028. * @param scene babylon scene object to use
  45029. * @param options (read-only) version of the options passed to this UI
  45030. */
  45031. private constructor();
  45032. /**
  45033. * Creates UI to allow the user to enter/exit XR mode
  45034. * @param scene the scene to add the ui to
  45035. * @param helper the xr experience helper to enter/exit xr with
  45036. * @param options options to configure the UI
  45037. * @returns the created ui
  45038. */
  45039. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45040. /**
  45041. * Disposes of the XR UI component
  45042. */
  45043. dispose(): void;
  45044. private _updateButtons;
  45045. }
  45046. }
  45047. declare module BABYLON {
  45048. /**
  45049. * Class containing static functions to help procedurally build meshes
  45050. */
  45051. export class LinesBuilder {
  45052. /**
  45053. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45054. * * 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
  45055. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45056. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45057. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45058. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45059. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45060. * * 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
  45061. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45064. * @param name defines the name of the new line system
  45065. * @param options defines the options used to create the line system
  45066. * @param scene defines the hosting scene
  45067. * @returns a new line system mesh
  45068. */
  45069. static CreateLineSystem(name: string, options: {
  45070. lines: Vector3[][];
  45071. updatable?: boolean;
  45072. instance?: Nullable<LinesMesh>;
  45073. colors?: Nullable<Color4[][]>;
  45074. useVertexAlpha?: boolean;
  45075. }, scene: Nullable<Scene>): LinesMesh;
  45076. /**
  45077. * Creates a line mesh
  45078. * 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
  45079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45080. * * The parameter `points` is an array successive Vector3
  45081. * * 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
  45082. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45083. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45084. * * When updating an instance, remember that only point positions can change, not the number of points
  45085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45087. * @param name defines the name of the new line system
  45088. * @param options defines the options used to create the line system
  45089. * @param scene defines the hosting scene
  45090. * @returns a new line mesh
  45091. */
  45092. static CreateLines(name: string, options: {
  45093. points: Vector3[];
  45094. updatable?: boolean;
  45095. instance?: Nullable<LinesMesh>;
  45096. colors?: Color4[];
  45097. useVertexAlpha?: boolean;
  45098. }, scene?: Nullable<Scene>): LinesMesh;
  45099. /**
  45100. * Creates a dashed line mesh
  45101. * * 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
  45102. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45103. * * The parameter `points` is an array successive Vector3
  45104. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45105. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45106. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45107. * * 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
  45108. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45109. * * When updating an instance, remember that only point positions can change, not the number of points
  45110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45111. * @param name defines the name of the mesh
  45112. * @param options defines the options used to create the mesh
  45113. * @param scene defines the hosting scene
  45114. * @returns the dashed line mesh
  45115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45116. */
  45117. static CreateDashedLines(name: string, options: {
  45118. points: Vector3[];
  45119. dashSize?: number;
  45120. gapSize?: number;
  45121. dashNb?: number;
  45122. updatable?: boolean;
  45123. instance?: LinesMesh;
  45124. useVertexAlpha?: boolean;
  45125. }, scene?: Nullable<Scene>): LinesMesh;
  45126. }
  45127. }
  45128. declare module BABYLON {
  45129. /**
  45130. * The options container for the teleportation module
  45131. */
  45132. export interface IWebXRTeleportationOptions {
  45133. /**
  45134. * if provided, this scene will be used to render meshes.
  45135. */
  45136. customUtilityLayerScene?: Scene;
  45137. /**
  45138. * Values to configure the default target mesh
  45139. */
  45140. defaultTargetMeshOptions?: {
  45141. /**
  45142. * Fill color of the teleportation area
  45143. */
  45144. teleportationFillColor?: string;
  45145. /**
  45146. * Border color for the teleportation area
  45147. */
  45148. teleportationBorderColor?: string;
  45149. /**
  45150. * Disable the mesh's animation sequence
  45151. */
  45152. disableAnimation?: boolean;
  45153. /**
  45154. * Disable lighting on the material or the ring and arrow
  45155. */
  45156. disableLighting?: boolean;
  45157. /**
  45158. * Override the default material of the torus and arrow
  45159. */
  45160. torusArrowMaterial?: Material;
  45161. };
  45162. /**
  45163. * A list of meshes to use as floor meshes.
  45164. * Meshes can be added and removed after initializing the feature using the
  45165. * addFloorMesh and removeFloorMesh functions
  45166. * If empty, rotation will still work
  45167. */
  45168. floorMeshes?: AbstractMesh[];
  45169. /**
  45170. * use this rendering group id for the meshes (optional)
  45171. */
  45172. renderingGroupId?: number;
  45173. /**
  45174. * Should teleportation move only to snap points
  45175. */
  45176. snapPointsOnly?: boolean;
  45177. /**
  45178. * An array of points to which the teleportation will snap to.
  45179. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45180. */
  45181. snapPositions?: Vector3[];
  45182. /**
  45183. * How close should the teleportation ray be in order to snap to position.
  45184. * Default to 0.8 units (meters)
  45185. */
  45186. snapToPositionRadius?: number;
  45187. /**
  45188. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45189. * If you want to support rotation, make sure your mesh has a direction indicator.
  45190. *
  45191. * When left untouched, the default mesh will be initialized.
  45192. */
  45193. teleportationTargetMesh?: AbstractMesh;
  45194. /**
  45195. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45196. */
  45197. timeToTeleport?: number;
  45198. /**
  45199. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45200. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45201. */
  45202. useMainComponentOnly?: boolean;
  45203. /**
  45204. * Should meshes created here be added to a utility layer or the main scene
  45205. */
  45206. useUtilityLayer?: boolean;
  45207. /**
  45208. * Babylon XR Input class for controller
  45209. */
  45210. xrInput: WebXRInput;
  45211. }
  45212. /**
  45213. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45214. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45215. * the input of the attached controllers.
  45216. */
  45217. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45218. private _options;
  45219. private _controllers;
  45220. private _currentTeleportationControllerId;
  45221. private _floorMeshes;
  45222. private _quadraticBezierCurve;
  45223. private _selectionFeature;
  45224. private _snapToPositions;
  45225. private _snappedToPoint;
  45226. private _teleportationRingMaterial?;
  45227. private _tmpRay;
  45228. private _tmpVector;
  45229. /**
  45230. * The module's name
  45231. */
  45232. static readonly Name: string;
  45233. /**
  45234. * The (Babylon) version of this module.
  45235. * This is an integer representing the implementation version.
  45236. * This number does not correspond to the webxr specs version
  45237. */
  45238. static readonly Version: number;
  45239. /**
  45240. * Is movement backwards enabled
  45241. */
  45242. backwardsMovementEnabled: boolean;
  45243. /**
  45244. * Distance to travel when moving backwards
  45245. */
  45246. backwardsTeleportationDistance: number;
  45247. /**
  45248. * The distance from the user to the inspection point in the direction of the controller
  45249. * A higher number will allow the user to move further
  45250. * defaults to 5 (meters, in xr units)
  45251. */
  45252. parabolicCheckRadius: number;
  45253. /**
  45254. * Should the module support parabolic ray on top of direct ray
  45255. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45256. * Very helpful when moving between floors / different heights
  45257. */
  45258. parabolicRayEnabled: boolean;
  45259. /**
  45260. * How much rotation should be applied when rotating right and left
  45261. */
  45262. rotationAngle: number;
  45263. /**
  45264. * Is rotation enabled when moving forward?
  45265. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45266. */
  45267. rotationEnabled: boolean;
  45268. /**
  45269. * constructs a new anchor system
  45270. * @param _xrSessionManager an instance of WebXRSessionManager
  45271. * @param _options configuration object for this feature
  45272. */
  45273. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45274. /**
  45275. * Get the snapPointsOnly flag
  45276. */
  45277. get snapPointsOnly(): boolean;
  45278. /**
  45279. * Sets the snapPointsOnly flag
  45280. * @param snapToPoints should teleportation be exclusively to snap points
  45281. */
  45282. set snapPointsOnly(snapToPoints: boolean);
  45283. /**
  45284. * Add a new mesh to the floor meshes array
  45285. * @param mesh the mesh to use as floor mesh
  45286. */
  45287. addFloorMesh(mesh: AbstractMesh): void;
  45288. /**
  45289. * Add a new snap-to point to fix teleportation to this position
  45290. * @param newSnapPoint The new Snap-To point
  45291. */
  45292. addSnapPoint(newSnapPoint: Vector3): void;
  45293. attach(): boolean;
  45294. detach(): boolean;
  45295. dispose(): void;
  45296. /**
  45297. * Remove a mesh from the floor meshes array
  45298. * @param mesh the mesh to remove
  45299. */
  45300. removeFloorMesh(mesh: AbstractMesh): void;
  45301. /**
  45302. * Remove a mesh from the floor meshes array using its name
  45303. * @param name the mesh name to remove
  45304. */
  45305. removeFloorMeshByName(name: string): void;
  45306. /**
  45307. * 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
  45308. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45309. * @returns was the point found and removed or not
  45310. */
  45311. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45312. /**
  45313. * This function sets a selection feature that will be disabled when
  45314. * the forward ray is shown and will be reattached when hidden.
  45315. * This is used to remove the selection rays when moving.
  45316. * @param selectionFeature the feature to disable when forward movement is enabled
  45317. */
  45318. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45319. protected _onXRFrame(_xrFrame: XRFrame): void;
  45320. private _attachController;
  45321. private _createDefaultTargetMesh;
  45322. private _detachController;
  45323. private _findClosestSnapPointWithRadius;
  45324. private _setTargetMeshPosition;
  45325. private _setTargetMeshVisibility;
  45326. private _showParabolicPath;
  45327. private _teleportForward;
  45328. }
  45329. }
  45330. declare module BABYLON {
  45331. /**
  45332. * Options for the default xr helper
  45333. */
  45334. export class WebXRDefaultExperienceOptions {
  45335. /**
  45336. * Enable or disable default UI to enter XR
  45337. */
  45338. disableDefaultUI?: boolean;
  45339. /**
  45340. * Should teleportation not initialize. defaults to false.
  45341. */
  45342. disableTeleportation?: boolean;
  45343. /**
  45344. * Floor meshes that will be used for teleport
  45345. */
  45346. floorMeshes?: Array<AbstractMesh>;
  45347. /**
  45348. * If set to true, the first frame will not be used to reset position
  45349. * The first frame is mainly used when copying transformation from the old camera
  45350. * Mainly used in AR
  45351. */
  45352. ignoreNativeCameraTransformation?: boolean;
  45353. /**
  45354. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45355. */
  45356. inputOptions?: IWebXRInputOptions;
  45357. /**
  45358. * optional configuration for the output canvas
  45359. */
  45360. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45361. /**
  45362. * optional UI options. This can be used among other to change session mode and reference space type
  45363. */
  45364. uiOptions?: WebXREnterExitUIOptions;
  45365. /**
  45366. * When loading teleportation and pointer select, use stable versions instead of latest.
  45367. */
  45368. useStablePlugins?: boolean;
  45369. }
  45370. /**
  45371. * Default experience which provides a similar setup to the previous webVRExperience
  45372. */
  45373. export class WebXRDefaultExperience {
  45374. /**
  45375. * Base experience
  45376. */
  45377. baseExperience: WebXRExperienceHelper;
  45378. /**
  45379. * Enables ui for entering/exiting xr
  45380. */
  45381. enterExitUI: WebXREnterExitUI;
  45382. /**
  45383. * Input experience extension
  45384. */
  45385. input: WebXRInput;
  45386. /**
  45387. * Enables laser pointer and selection
  45388. */
  45389. pointerSelection: WebXRControllerPointerSelection;
  45390. /**
  45391. * Default target xr should render to
  45392. */
  45393. renderTarget: WebXRRenderTarget;
  45394. /**
  45395. * Enables teleportation
  45396. */
  45397. teleportation: WebXRMotionControllerTeleportation;
  45398. private constructor();
  45399. /**
  45400. * Creates the default xr experience
  45401. * @param scene scene
  45402. * @param options options for basic configuration
  45403. * @returns resulting WebXRDefaultExperience
  45404. */
  45405. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45406. /**
  45407. * DIsposes of the experience helper
  45408. */
  45409. dispose(): void;
  45410. }
  45411. }
  45412. declare module BABYLON {
  45413. /**
  45414. * Options to modify the vr teleportation behavior.
  45415. */
  45416. export interface VRTeleportationOptions {
  45417. /**
  45418. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45419. */
  45420. floorMeshName?: string;
  45421. /**
  45422. * A list of meshes to be used as the teleportation floor. (default: empty)
  45423. */
  45424. floorMeshes?: Mesh[];
  45425. /**
  45426. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45427. */
  45428. teleportationMode?: number;
  45429. /**
  45430. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45431. */
  45432. teleportationTime?: number;
  45433. /**
  45434. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45435. */
  45436. teleportationSpeed?: number;
  45437. /**
  45438. * The easing function used in the animation or null for Linear. (default CircleEase)
  45439. */
  45440. easingFunction?: EasingFunction;
  45441. }
  45442. /**
  45443. * Options to modify the vr experience helper's behavior.
  45444. */
  45445. export interface VRExperienceHelperOptions extends WebVROptions {
  45446. /**
  45447. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45448. */
  45449. createDeviceOrientationCamera?: boolean;
  45450. /**
  45451. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45452. */
  45453. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45454. /**
  45455. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45456. */
  45457. laserToggle?: boolean;
  45458. /**
  45459. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45460. */
  45461. floorMeshes?: Mesh[];
  45462. /**
  45463. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45464. */
  45465. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45466. /**
  45467. * Defines if WebXR should be used instead of WebVR (if available)
  45468. */
  45469. useXR?: boolean;
  45470. }
  45471. /**
  45472. * Event containing information after VR has been entered
  45473. */
  45474. export class OnAfterEnteringVRObservableEvent {
  45475. /**
  45476. * If entering vr was successful
  45477. */
  45478. success: boolean;
  45479. }
  45480. /**
  45481. * Helps to quickly add VR support to an existing scene.
  45482. * See http://doc.babylonjs.com/how_to/webvr_helper
  45483. */
  45484. export class VRExperienceHelper {
  45485. /** Options to modify the vr experience helper's behavior. */
  45486. webVROptions: VRExperienceHelperOptions;
  45487. private _scene;
  45488. private _position;
  45489. private _btnVR;
  45490. private _btnVRDisplayed;
  45491. private _webVRsupported;
  45492. private _webVRready;
  45493. private _webVRrequesting;
  45494. private _webVRpresenting;
  45495. private _hasEnteredVR;
  45496. private _fullscreenVRpresenting;
  45497. private _inputElement;
  45498. private _webVRCamera;
  45499. private _vrDeviceOrientationCamera;
  45500. private _deviceOrientationCamera;
  45501. private _existingCamera;
  45502. private _onKeyDown;
  45503. private _onVrDisplayPresentChange;
  45504. private _onVRDisplayChanged;
  45505. private _onVRRequestPresentStart;
  45506. private _onVRRequestPresentComplete;
  45507. /**
  45508. * 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)
  45509. */
  45510. enableGazeEvenWhenNoPointerLock: boolean;
  45511. /**
  45512. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45513. */
  45514. exitVROnDoubleTap: boolean;
  45515. /**
  45516. * Observable raised right before entering VR.
  45517. */
  45518. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45519. /**
  45520. * Observable raised when entering VR has completed.
  45521. */
  45522. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45523. /**
  45524. * Observable raised when exiting VR.
  45525. */
  45526. onExitingVRObservable: Observable<VRExperienceHelper>;
  45527. /**
  45528. * Observable raised when controller mesh is loaded.
  45529. */
  45530. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45531. /** Return this.onEnteringVRObservable
  45532. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45533. */
  45534. get onEnteringVR(): Observable<VRExperienceHelper>;
  45535. /** Return this.onExitingVRObservable
  45536. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45537. */
  45538. get onExitingVR(): Observable<VRExperienceHelper>;
  45539. /** Return this.onControllerMeshLoadedObservable
  45540. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45541. */
  45542. get onControllerMeshLoaded(): Observable<WebVRController>;
  45543. private _rayLength;
  45544. private _useCustomVRButton;
  45545. private _teleportationRequested;
  45546. private _teleportActive;
  45547. private _floorMeshName;
  45548. private _floorMeshesCollection;
  45549. private _teleportationMode;
  45550. private _teleportationTime;
  45551. private _teleportationSpeed;
  45552. private _teleportationEasing;
  45553. private _rotationAllowed;
  45554. private _teleportBackwardsVector;
  45555. private _teleportationTarget;
  45556. private _isDefaultTeleportationTarget;
  45557. private _postProcessMove;
  45558. private _teleportationFillColor;
  45559. private _teleportationBorderColor;
  45560. private _rotationAngle;
  45561. private _haloCenter;
  45562. private _cameraGazer;
  45563. private _padSensibilityUp;
  45564. private _padSensibilityDown;
  45565. private _leftController;
  45566. private _rightController;
  45567. private _gazeColor;
  45568. private _laserColor;
  45569. private _pickedLaserColor;
  45570. private _pickedGazeColor;
  45571. /**
  45572. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45573. */
  45574. onNewMeshSelected: Observable<AbstractMesh>;
  45575. /**
  45576. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45577. * This observable will provide the mesh and the controller used to select the mesh
  45578. */
  45579. onMeshSelectedWithController: Observable<{
  45580. mesh: AbstractMesh;
  45581. controller: WebVRController;
  45582. }>;
  45583. /**
  45584. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45585. */
  45586. onNewMeshPicked: Observable<PickingInfo>;
  45587. private _circleEase;
  45588. /**
  45589. * Observable raised before camera teleportation
  45590. */
  45591. onBeforeCameraTeleport: Observable<Vector3>;
  45592. /**
  45593. * Observable raised after camera teleportation
  45594. */
  45595. onAfterCameraTeleport: Observable<Vector3>;
  45596. /**
  45597. * Observable raised when current selected mesh gets unselected
  45598. */
  45599. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45600. private _raySelectionPredicate;
  45601. /**
  45602. * To be optionaly changed by user to define custom ray selection
  45603. */
  45604. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45605. /**
  45606. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45607. */
  45608. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45609. /**
  45610. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45611. */
  45612. teleportationEnabled: boolean;
  45613. private _defaultHeight;
  45614. private _teleportationInitialized;
  45615. private _interactionsEnabled;
  45616. private _interactionsRequested;
  45617. private _displayGaze;
  45618. private _displayLaserPointer;
  45619. /**
  45620. * The mesh used to display where the user is going to teleport.
  45621. */
  45622. get teleportationTarget(): Mesh;
  45623. /**
  45624. * Sets the mesh to be used to display where the user is going to teleport.
  45625. */
  45626. set teleportationTarget(value: Mesh);
  45627. /**
  45628. * 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
  45629. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45630. * See http://doc.babylonjs.com/resources/baking_transformations
  45631. */
  45632. get gazeTrackerMesh(): Mesh;
  45633. set gazeTrackerMesh(value: Mesh);
  45634. /**
  45635. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45636. */
  45637. updateGazeTrackerScale: boolean;
  45638. /**
  45639. * If the gaze trackers color should be updated when selecting meshes
  45640. */
  45641. updateGazeTrackerColor: boolean;
  45642. /**
  45643. * If the controller laser color should be updated when selecting meshes
  45644. */
  45645. updateControllerLaserColor: boolean;
  45646. /**
  45647. * The gaze tracking mesh corresponding to the left controller
  45648. */
  45649. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45650. /**
  45651. * The gaze tracking mesh corresponding to the right controller
  45652. */
  45653. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45654. /**
  45655. * If the ray of the gaze should be displayed.
  45656. */
  45657. get displayGaze(): boolean;
  45658. /**
  45659. * Sets if the ray of the gaze should be displayed.
  45660. */
  45661. set displayGaze(value: boolean);
  45662. /**
  45663. * If the ray of the LaserPointer should be displayed.
  45664. */
  45665. get displayLaserPointer(): boolean;
  45666. /**
  45667. * Sets if the ray of the LaserPointer should be displayed.
  45668. */
  45669. set displayLaserPointer(value: boolean);
  45670. /**
  45671. * The deviceOrientationCamera used as the camera when not in VR.
  45672. */
  45673. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45674. /**
  45675. * Based on the current WebVR support, returns the current VR camera used.
  45676. */
  45677. get currentVRCamera(): Nullable<Camera>;
  45678. /**
  45679. * The webVRCamera which is used when in VR.
  45680. */
  45681. get webVRCamera(): WebVRFreeCamera;
  45682. /**
  45683. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45684. */
  45685. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45686. /**
  45687. * The html button that is used to trigger entering into VR.
  45688. */
  45689. get vrButton(): Nullable<HTMLButtonElement>;
  45690. private get _teleportationRequestInitiated();
  45691. /**
  45692. * Defines whether or not Pointer lock should be requested when switching to
  45693. * full screen.
  45694. */
  45695. requestPointerLockOnFullScreen: boolean;
  45696. /**
  45697. * If asking to force XR, this will be populated with the default xr experience
  45698. */
  45699. xr: WebXRDefaultExperience;
  45700. /**
  45701. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45702. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45703. */
  45704. xrTestDone: boolean;
  45705. /**
  45706. * Instantiates a VRExperienceHelper.
  45707. * Helps to quickly add VR support to an existing scene.
  45708. * @param scene The scene the VRExperienceHelper belongs to.
  45709. * @param webVROptions Options to modify the vr experience helper's behavior.
  45710. */
  45711. constructor(scene: Scene,
  45712. /** Options to modify the vr experience helper's behavior. */
  45713. webVROptions?: VRExperienceHelperOptions);
  45714. private completeVRInit;
  45715. private _onDefaultMeshLoaded;
  45716. private _onResize;
  45717. private _onFullscreenChange;
  45718. /**
  45719. * Gets a value indicating if we are currently in VR mode.
  45720. */
  45721. get isInVRMode(): boolean;
  45722. private onVrDisplayPresentChange;
  45723. private onVRDisplayChanged;
  45724. private moveButtonToBottomRight;
  45725. private displayVRButton;
  45726. private updateButtonVisibility;
  45727. private _cachedAngularSensibility;
  45728. /**
  45729. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45730. * Otherwise, will use the fullscreen API.
  45731. */
  45732. enterVR(): void;
  45733. /**
  45734. * Attempt to exit VR, or fullscreen.
  45735. */
  45736. exitVR(): void;
  45737. /**
  45738. * The position of the vr experience helper.
  45739. */
  45740. get position(): Vector3;
  45741. /**
  45742. * Sets the position of the vr experience helper.
  45743. */
  45744. set position(value: Vector3);
  45745. /**
  45746. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45747. */
  45748. enableInteractions(): void;
  45749. private get _noControllerIsActive();
  45750. private beforeRender;
  45751. private _isTeleportationFloor;
  45752. /**
  45753. * Adds a floor mesh to be used for teleportation.
  45754. * @param floorMesh the mesh to be used for teleportation.
  45755. */
  45756. addFloorMesh(floorMesh: Mesh): void;
  45757. /**
  45758. * Removes a floor mesh from being used for teleportation.
  45759. * @param floorMesh the mesh to be removed.
  45760. */
  45761. removeFloorMesh(floorMesh: Mesh): void;
  45762. /**
  45763. * Enables interactions and teleportation using the VR controllers and gaze.
  45764. * @param vrTeleportationOptions options to modify teleportation behavior.
  45765. */
  45766. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45767. private _onNewGamepadConnected;
  45768. private _tryEnableInteractionOnController;
  45769. private _onNewGamepadDisconnected;
  45770. private _enableInteractionOnController;
  45771. private _checkTeleportWithRay;
  45772. private _checkRotate;
  45773. private _checkTeleportBackwards;
  45774. private _enableTeleportationOnController;
  45775. private _createTeleportationCircles;
  45776. private _displayTeleportationTarget;
  45777. private _hideTeleportationTarget;
  45778. private _rotateCamera;
  45779. private _moveTeleportationSelectorTo;
  45780. private _workingVector;
  45781. private _workingQuaternion;
  45782. private _workingMatrix;
  45783. /**
  45784. * Time Constant Teleportation Mode
  45785. */
  45786. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45787. /**
  45788. * Speed Constant Teleportation Mode
  45789. */
  45790. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45791. /**
  45792. * Teleports the users feet to the desired location
  45793. * @param location The location where the user's feet should be placed
  45794. */
  45795. teleportCamera(location: Vector3): void;
  45796. private _convertNormalToDirectionOfRay;
  45797. private _castRayAndSelectObject;
  45798. private _notifySelectedMeshUnselected;
  45799. /**
  45800. * Permanently set new colors for the laser pointer
  45801. * @param color the new laser color
  45802. * @param pickedColor the new laser color when picked mesh detected
  45803. */
  45804. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45805. /**
  45806. * Set lighting enabled / disabled on the laser pointer of both controllers
  45807. * @param enabled should the lighting be enabled on the laser pointer
  45808. */
  45809. setLaserLightingState(enabled?: boolean): void;
  45810. /**
  45811. * Permanently set new colors for the gaze pointer
  45812. * @param color the new gaze color
  45813. * @param pickedColor the new gaze color when picked mesh detected
  45814. */
  45815. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45816. /**
  45817. * Sets the color of the laser ray from the vr controllers.
  45818. * @param color new color for the ray.
  45819. */
  45820. changeLaserColor(color: Color3): void;
  45821. /**
  45822. * Sets the color of the ray from the vr headsets gaze.
  45823. * @param color new color for the ray.
  45824. */
  45825. changeGazeColor(color: Color3): void;
  45826. /**
  45827. * Exits VR and disposes of the vr experience helper
  45828. */
  45829. dispose(): void;
  45830. /**
  45831. * Gets the name of the VRExperienceHelper class
  45832. * @returns "VRExperienceHelper"
  45833. */
  45834. getClassName(): string;
  45835. }
  45836. }
  45837. declare module BABYLON {
  45838. /**
  45839. * Contains an array of blocks representing the octree
  45840. */
  45841. export interface IOctreeContainer<T> {
  45842. /**
  45843. * Blocks within the octree
  45844. */
  45845. blocks: Array<OctreeBlock<T>>;
  45846. }
  45847. /**
  45848. * Class used to store a cell in an octree
  45849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45850. */
  45851. export class OctreeBlock<T> {
  45852. /**
  45853. * Gets the content of the current block
  45854. */
  45855. entries: T[];
  45856. /**
  45857. * Gets the list of block children
  45858. */
  45859. blocks: Array<OctreeBlock<T>>;
  45860. private _depth;
  45861. private _maxDepth;
  45862. private _capacity;
  45863. private _minPoint;
  45864. private _maxPoint;
  45865. private _boundingVectors;
  45866. private _creationFunc;
  45867. /**
  45868. * Creates a new block
  45869. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45870. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45871. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45872. * @param depth defines the current depth of this block in the octree
  45873. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45874. * @param creationFunc defines a callback to call when an element is added to the block
  45875. */
  45876. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45877. /**
  45878. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45879. */
  45880. get capacity(): number;
  45881. /**
  45882. * Gets the minimum vector (in world space) of the block's bounding box
  45883. */
  45884. get minPoint(): Vector3;
  45885. /**
  45886. * Gets the maximum vector (in world space) of the block's bounding box
  45887. */
  45888. get maxPoint(): Vector3;
  45889. /**
  45890. * Add a new element to this block
  45891. * @param entry defines the element to add
  45892. */
  45893. addEntry(entry: T): void;
  45894. /**
  45895. * Remove an element from this block
  45896. * @param entry defines the element to remove
  45897. */
  45898. removeEntry(entry: T): void;
  45899. /**
  45900. * Add an array of elements to this block
  45901. * @param entries defines the array of elements to add
  45902. */
  45903. addEntries(entries: T[]): void;
  45904. /**
  45905. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45906. * @param frustumPlanes defines the frustum planes to test
  45907. * @param selection defines the array to store current content if selection is positive
  45908. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45909. */
  45910. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45911. /**
  45912. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45913. * @param sphereCenter defines the bounding sphere center
  45914. * @param sphereRadius defines the bounding sphere radius
  45915. * @param selection defines the array to store current content if selection is positive
  45916. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45917. */
  45918. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45919. /**
  45920. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45921. * @param ray defines the ray to test with
  45922. * @param selection defines the array to store current content if selection is positive
  45923. */
  45924. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45925. /**
  45926. * Subdivide the content into child blocks (this block will then be empty)
  45927. */
  45928. createInnerBlocks(): void;
  45929. /**
  45930. * @hidden
  45931. */
  45932. 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;
  45933. }
  45934. }
  45935. declare module BABYLON {
  45936. /**
  45937. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45938. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45939. */
  45940. export class Octree<T> {
  45941. /** 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.) */
  45942. maxDepth: number;
  45943. /**
  45944. * Blocks within the octree containing objects
  45945. */
  45946. blocks: Array<OctreeBlock<T>>;
  45947. /**
  45948. * Content stored in the octree
  45949. */
  45950. dynamicContent: T[];
  45951. private _maxBlockCapacity;
  45952. private _selectionContent;
  45953. private _creationFunc;
  45954. /**
  45955. * Creates a octree
  45956. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45957. * @param creationFunc function to be used to instatiate the octree
  45958. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45959. * @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.)
  45960. */
  45961. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45962. /** 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.) */
  45963. maxDepth?: number);
  45964. /**
  45965. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45966. * @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);
  45967. * @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);
  45968. * @param entries meshes to be added to the octree blocks
  45969. */
  45970. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45971. /**
  45972. * Adds a mesh to the octree
  45973. * @param entry Mesh to add to the octree
  45974. */
  45975. addMesh(entry: T): void;
  45976. /**
  45977. * Remove an element from the octree
  45978. * @param entry defines the element to remove
  45979. */
  45980. removeMesh(entry: T): void;
  45981. /**
  45982. * Selects an array of meshes within the frustum
  45983. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45984. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45985. * @returns array of meshes within the frustum
  45986. */
  45987. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45988. /**
  45989. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45990. * @param sphereCenter defines the bounding sphere center
  45991. * @param sphereRadius defines the bounding sphere radius
  45992. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45993. * @returns an array of objects that intersect the sphere
  45994. */
  45995. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45996. /**
  45997. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45998. * @param ray defines the ray to test with
  45999. * @returns array of intersected objects
  46000. */
  46001. intersectsRay(ray: Ray): SmartArray<T>;
  46002. /**
  46003. * Adds a mesh into the octree block if it intersects the block
  46004. */
  46005. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46006. /**
  46007. * Adds a submesh into the octree block if it intersects the block
  46008. */
  46009. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46010. }
  46011. }
  46012. declare module BABYLON {
  46013. interface Scene {
  46014. /**
  46015. * @hidden
  46016. * Backing Filed
  46017. */
  46018. _selectionOctree: Octree<AbstractMesh>;
  46019. /**
  46020. * Gets the octree used to boost mesh selection (picking)
  46021. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46022. */
  46023. selectionOctree: Octree<AbstractMesh>;
  46024. /**
  46025. * Creates or updates the octree used to boost selection (picking)
  46026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46027. * @param maxCapacity defines the maximum capacity per leaf
  46028. * @param maxDepth defines the maximum depth of the octree
  46029. * @returns an octree of AbstractMesh
  46030. */
  46031. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46032. }
  46033. interface AbstractMesh {
  46034. /**
  46035. * @hidden
  46036. * Backing Field
  46037. */
  46038. _submeshesOctree: Octree<SubMesh>;
  46039. /**
  46040. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46041. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46042. * @param maxCapacity defines the maximum size of each block (64 by default)
  46043. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46044. * @returns the new octree
  46045. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46047. */
  46048. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46049. }
  46050. /**
  46051. * Defines the octree scene component responsible to manage any octrees
  46052. * in a given scene.
  46053. */
  46054. export class OctreeSceneComponent {
  46055. /**
  46056. * The component name help to identify the component in the list of scene components.
  46057. */
  46058. readonly name: string;
  46059. /**
  46060. * The scene the component belongs to.
  46061. */
  46062. scene: Scene;
  46063. /**
  46064. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46065. */
  46066. readonly checksIsEnabled: boolean;
  46067. /**
  46068. * Creates a new instance of the component for the given scene
  46069. * @param scene Defines the scene to register the component in
  46070. */
  46071. constructor(scene: Scene);
  46072. /**
  46073. * Registers the component in a given scene
  46074. */
  46075. register(): void;
  46076. /**
  46077. * Return the list of active meshes
  46078. * @returns the list of active meshes
  46079. */
  46080. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46081. /**
  46082. * Return the list of active sub meshes
  46083. * @param mesh The mesh to get the candidates sub meshes from
  46084. * @returns the list of active sub meshes
  46085. */
  46086. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46087. private _tempRay;
  46088. /**
  46089. * Return the list of sub meshes intersecting with a given local ray
  46090. * @param mesh defines the mesh to find the submesh for
  46091. * @param localRay defines the ray in local space
  46092. * @returns the list of intersecting sub meshes
  46093. */
  46094. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46095. /**
  46096. * Return the list of sub meshes colliding with a collider
  46097. * @param mesh defines the mesh to find the submesh for
  46098. * @param collider defines the collider to evaluate the collision against
  46099. * @returns the list of colliding sub meshes
  46100. */
  46101. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46102. /**
  46103. * Rebuilds the elements related to this component in case of
  46104. * context lost for instance.
  46105. */
  46106. rebuild(): void;
  46107. /**
  46108. * Disposes the component and the associated ressources.
  46109. */
  46110. dispose(): void;
  46111. }
  46112. }
  46113. declare module BABYLON {
  46114. /**
  46115. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46116. */
  46117. export class Gizmo implements IDisposable {
  46118. /** The utility layer the gizmo will be added to */
  46119. gizmoLayer: UtilityLayerRenderer;
  46120. /**
  46121. * The root mesh of the gizmo
  46122. */
  46123. _rootMesh: Mesh;
  46124. private _attachedMesh;
  46125. /**
  46126. * Ratio for the scale of the gizmo (Default: 1)
  46127. */
  46128. scaleRatio: number;
  46129. /**
  46130. * If a custom mesh has been set (Default: false)
  46131. */
  46132. protected _customMeshSet: boolean;
  46133. /**
  46134. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46135. * * When set, interactions will be enabled
  46136. */
  46137. get attachedMesh(): Nullable<AbstractMesh>;
  46138. set attachedMesh(value: Nullable<AbstractMesh>);
  46139. /**
  46140. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46141. * @param mesh The mesh to replace the default mesh of the gizmo
  46142. */
  46143. setCustomMesh(mesh: Mesh): void;
  46144. /**
  46145. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46146. */
  46147. updateGizmoRotationToMatchAttachedMesh: boolean;
  46148. /**
  46149. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46150. */
  46151. updateGizmoPositionToMatchAttachedMesh: boolean;
  46152. /**
  46153. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46154. */
  46155. updateScale: boolean;
  46156. protected _interactionsEnabled: boolean;
  46157. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46158. private _beforeRenderObserver;
  46159. private _tempVector;
  46160. /**
  46161. * Creates a gizmo
  46162. * @param gizmoLayer The utility layer the gizmo will be added to
  46163. */
  46164. constructor(
  46165. /** The utility layer the gizmo will be added to */
  46166. gizmoLayer?: UtilityLayerRenderer);
  46167. /**
  46168. * Updates the gizmo to match the attached mesh's position/rotation
  46169. */
  46170. protected _update(): void;
  46171. /**
  46172. * Disposes of the gizmo
  46173. */
  46174. dispose(): void;
  46175. }
  46176. }
  46177. declare module BABYLON {
  46178. /**
  46179. * Single plane drag gizmo
  46180. */
  46181. export class PlaneDragGizmo extends Gizmo {
  46182. /**
  46183. * Drag behavior responsible for the gizmos dragging interactions
  46184. */
  46185. dragBehavior: PointerDragBehavior;
  46186. private _pointerObserver;
  46187. /**
  46188. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46189. */
  46190. snapDistance: number;
  46191. /**
  46192. * Event that fires each time the gizmo snaps to a new location.
  46193. * * snapDistance is the the change in distance
  46194. */
  46195. onSnapObservable: Observable<{
  46196. snapDistance: number;
  46197. }>;
  46198. private _plane;
  46199. private _coloredMaterial;
  46200. private _hoverMaterial;
  46201. private _isEnabled;
  46202. private _parent;
  46203. /** @hidden */
  46204. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46205. /** @hidden */
  46206. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46207. /**
  46208. * Creates a PlaneDragGizmo
  46209. * @param gizmoLayer The utility layer the gizmo will be added to
  46210. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46211. * @param color The color of the gizmo
  46212. */
  46213. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46214. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46215. /**
  46216. * If the gizmo is enabled
  46217. */
  46218. set isEnabled(value: boolean);
  46219. get isEnabled(): boolean;
  46220. /**
  46221. * Disposes of the gizmo
  46222. */
  46223. dispose(): void;
  46224. }
  46225. }
  46226. declare module BABYLON {
  46227. /**
  46228. * Gizmo that enables dragging a mesh along 3 axis
  46229. */
  46230. export class PositionGizmo extends Gizmo {
  46231. /**
  46232. * Internal gizmo used for interactions on the x axis
  46233. */
  46234. xGizmo: AxisDragGizmo;
  46235. /**
  46236. * Internal gizmo used for interactions on the y axis
  46237. */
  46238. yGizmo: AxisDragGizmo;
  46239. /**
  46240. * Internal gizmo used for interactions on the z axis
  46241. */
  46242. zGizmo: AxisDragGizmo;
  46243. /**
  46244. * Internal gizmo used for interactions on the yz plane
  46245. */
  46246. xPlaneGizmo: PlaneDragGizmo;
  46247. /**
  46248. * Internal gizmo used for interactions on the xz plane
  46249. */
  46250. yPlaneGizmo: PlaneDragGizmo;
  46251. /**
  46252. * Internal gizmo used for interactions on the xy plane
  46253. */
  46254. zPlaneGizmo: PlaneDragGizmo;
  46255. /**
  46256. * private variables
  46257. */
  46258. private _meshAttached;
  46259. private _updateGizmoRotationToMatchAttachedMesh;
  46260. private _snapDistance;
  46261. private _scaleRatio;
  46262. /** Fires an event when any of it's sub gizmos are dragged */
  46263. onDragStartObservable: Observable<unknown>;
  46264. /** Fires an event when any of it's sub gizmos are released from dragging */
  46265. onDragEndObservable: Observable<unknown>;
  46266. /**
  46267. * If set to true, planar drag is enabled
  46268. */
  46269. private _planarGizmoEnabled;
  46270. get attachedMesh(): Nullable<AbstractMesh>;
  46271. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46272. /**
  46273. * Creates a PositionGizmo
  46274. * @param gizmoLayer The utility layer the gizmo will be added to
  46275. */
  46276. constructor(gizmoLayer?: UtilityLayerRenderer);
  46277. /**
  46278. * If the planar drag gizmo is enabled
  46279. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46280. */
  46281. set planarGizmoEnabled(value: boolean);
  46282. get planarGizmoEnabled(): boolean;
  46283. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46284. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46285. /**
  46286. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46287. */
  46288. set snapDistance(value: number);
  46289. get snapDistance(): number;
  46290. /**
  46291. * Ratio for the scale of the gizmo (Default: 1)
  46292. */
  46293. set scaleRatio(value: number);
  46294. get scaleRatio(): number;
  46295. /**
  46296. * Disposes of the gizmo
  46297. */
  46298. dispose(): void;
  46299. /**
  46300. * CustomMeshes are not supported by this gizmo
  46301. * @param mesh The mesh to replace the default mesh of the gizmo
  46302. */
  46303. setCustomMesh(mesh: Mesh): void;
  46304. }
  46305. }
  46306. declare module BABYLON {
  46307. /**
  46308. * Single axis drag gizmo
  46309. */
  46310. export class AxisDragGizmo extends Gizmo {
  46311. /**
  46312. * Drag behavior responsible for the gizmos dragging interactions
  46313. */
  46314. dragBehavior: PointerDragBehavior;
  46315. private _pointerObserver;
  46316. /**
  46317. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46318. */
  46319. snapDistance: number;
  46320. /**
  46321. * Event that fires each time the gizmo snaps to a new location.
  46322. * * snapDistance is the the change in distance
  46323. */
  46324. onSnapObservable: Observable<{
  46325. snapDistance: number;
  46326. }>;
  46327. private _isEnabled;
  46328. private _parent;
  46329. private _arrow;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. /** @hidden */
  46333. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46334. /** @hidden */
  46335. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46336. /**
  46337. * Creates an AxisDragGizmo
  46338. * @param gizmoLayer The utility layer the gizmo will be added to
  46339. * @param dragAxis The axis which the gizmo will be able to drag on
  46340. * @param color The color of the gizmo
  46341. */
  46342. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46344. /**
  46345. * If the gizmo is enabled
  46346. */
  46347. set isEnabled(value: boolean);
  46348. get isEnabled(): boolean;
  46349. /**
  46350. * Disposes of the gizmo
  46351. */
  46352. dispose(): void;
  46353. }
  46354. }
  46355. declare module BABYLON.Debug {
  46356. /**
  46357. * The Axes viewer will show 3 axes in a specific point in space
  46358. */
  46359. export class AxesViewer {
  46360. private _xAxis;
  46361. private _yAxis;
  46362. private _zAxis;
  46363. private _scaleLinesFactor;
  46364. private _instanced;
  46365. /**
  46366. * Gets the hosting scene
  46367. */
  46368. scene: Scene;
  46369. /**
  46370. * Gets or sets a number used to scale line length
  46371. */
  46372. scaleLines: number;
  46373. /** Gets the node hierarchy used to render x-axis */
  46374. get xAxis(): TransformNode;
  46375. /** Gets the node hierarchy used to render y-axis */
  46376. get yAxis(): TransformNode;
  46377. /** Gets the node hierarchy used to render z-axis */
  46378. get zAxis(): TransformNode;
  46379. /**
  46380. * Creates a new AxesViewer
  46381. * @param scene defines the hosting scene
  46382. * @param scaleLines defines a number used to scale line length (1 by default)
  46383. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46384. * @param xAxis defines the node hierarchy used to render the x-axis
  46385. * @param yAxis defines the node hierarchy used to render the y-axis
  46386. * @param zAxis defines the node hierarchy used to render the z-axis
  46387. */
  46388. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46389. /**
  46390. * Force the viewer to update
  46391. * @param position defines the position of the viewer
  46392. * @param xaxis defines the x axis of the viewer
  46393. * @param yaxis defines the y axis of the viewer
  46394. * @param zaxis defines the z axis of the viewer
  46395. */
  46396. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46397. /**
  46398. * Creates an instance of this axes viewer.
  46399. * @returns a new axes viewer with instanced meshes
  46400. */
  46401. createInstance(): AxesViewer;
  46402. /** Releases resources */
  46403. dispose(): void;
  46404. private static _SetRenderingGroupId;
  46405. }
  46406. }
  46407. declare module BABYLON.Debug {
  46408. /**
  46409. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46410. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46411. */
  46412. export class BoneAxesViewer extends AxesViewer {
  46413. /**
  46414. * Gets or sets the target mesh where to display the axes viewer
  46415. */
  46416. mesh: Nullable<Mesh>;
  46417. /**
  46418. * Gets or sets the target bone where to display the axes viewer
  46419. */
  46420. bone: Nullable<Bone>;
  46421. /** Gets current position */
  46422. pos: Vector3;
  46423. /** Gets direction of X axis */
  46424. xaxis: Vector3;
  46425. /** Gets direction of Y axis */
  46426. yaxis: Vector3;
  46427. /** Gets direction of Z axis */
  46428. zaxis: Vector3;
  46429. /**
  46430. * Creates a new BoneAxesViewer
  46431. * @param scene defines the hosting scene
  46432. * @param bone defines the target bone
  46433. * @param mesh defines the target mesh
  46434. * @param scaleLines defines a scaling factor for line length (1 by default)
  46435. */
  46436. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46437. /**
  46438. * Force the viewer to update
  46439. */
  46440. update(): void;
  46441. /** Releases resources */
  46442. dispose(): void;
  46443. }
  46444. }
  46445. declare module BABYLON {
  46446. /**
  46447. * Interface used to define scene explorer extensibility option
  46448. */
  46449. export interface IExplorerExtensibilityOption {
  46450. /**
  46451. * Define the option label
  46452. */
  46453. label: string;
  46454. /**
  46455. * Defines the action to execute on click
  46456. */
  46457. action: (entity: any) => void;
  46458. }
  46459. /**
  46460. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46461. */
  46462. export interface IExplorerExtensibilityGroup {
  46463. /**
  46464. * Defines a predicate to test if a given type mut be extended
  46465. */
  46466. predicate: (entity: any) => boolean;
  46467. /**
  46468. * Gets the list of options added to a type
  46469. */
  46470. entries: IExplorerExtensibilityOption[];
  46471. }
  46472. /**
  46473. * Interface used to define the options to use to create the Inspector
  46474. */
  46475. export interface IInspectorOptions {
  46476. /**
  46477. * Display in overlay mode (default: false)
  46478. */
  46479. overlay?: boolean;
  46480. /**
  46481. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46482. */
  46483. globalRoot?: HTMLElement;
  46484. /**
  46485. * Display the Scene explorer
  46486. */
  46487. showExplorer?: boolean;
  46488. /**
  46489. * Display the property inspector
  46490. */
  46491. showInspector?: boolean;
  46492. /**
  46493. * Display in embed mode (both panes on the right)
  46494. */
  46495. embedMode?: boolean;
  46496. /**
  46497. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46498. */
  46499. handleResize?: boolean;
  46500. /**
  46501. * Allow the panes to popup (default: true)
  46502. */
  46503. enablePopup?: boolean;
  46504. /**
  46505. * Allow the panes to be closed by users (default: true)
  46506. */
  46507. enableClose?: boolean;
  46508. /**
  46509. * Optional list of extensibility entries
  46510. */
  46511. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46512. /**
  46513. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46514. */
  46515. inspectorURL?: string;
  46516. /**
  46517. * Optional initial tab (default to DebugLayerTab.Properties)
  46518. */
  46519. initialTab?: DebugLayerTab;
  46520. }
  46521. interface Scene {
  46522. /**
  46523. * @hidden
  46524. * Backing field
  46525. */
  46526. _debugLayer: DebugLayer;
  46527. /**
  46528. * Gets the debug layer (aka Inspector) associated with the scene
  46529. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46530. */
  46531. debugLayer: DebugLayer;
  46532. }
  46533. /**
  46534. * Enum of inspector action tab
  46535. */
  46536. export enum DebugLayerTab {
  46537. /**
  46538. * Properties tag (default)
  46539. */
  46540. Properties = 0,
  46541. /**
  46542. * Debug tab
  46543. */
  46544. Debug = 1,
  46545. /**
  46546. * Statistics tab
  46547. */
  46548. Statistics = 2,
  46549. /**
  46550. * Tools tab
  46551. */
  46552. Tools = 3,
  46553. /**
  46554. * Settings tab
  46555. */
  46556. Settings = 4
  46557. }
  46558. /**
  46559. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46560. * what is happening in your scene
  46561. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46562. */
  46563. export class DebugLayer {
  46564. /**
  46565. * Define the url to get the inspector script from.
  46566. * By default it uses the babylonjs CDN.
  46567. * @ignoreNaming
  46568. */
  46569. static InspectorURL: string;
  46570. private _scene;
  46571. private BJSINSPECTOR;
  46572. private _onPropertyChangedObservable?;
  46573. /**
  46574. * Observable triggered when a property is changed through the inspector.
  46575. */
  46576. get onPropertyChangedObservable(): any;
  46577. /**
  46578. * Instantiates a new debug layer.
  46579. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46580. * what is happening in your scene
  46581. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46582. * @param scene Defines the scene to inspect
  46583. */
  46584. constructor(scene: Scene);
  46585. /** Creates the inspector window. */
  46586. private _createInspector;
  46587. /**
  46588. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46589. * @param entity defines the entity to select
  46590. * @param lineContainerTitle defines the specific block to highlight
  46591. */
  46592. select(entity: any, lineContainerTitle?: string): void;
  46593. /** Get the inspector from bundle or global */
  46594. private _getGlobalInspector;
  46595. /**
  46596. * Get if the inspector is visible or not.
  46597. * @returns true if visible otherwise, false
  46598. */
  46599. isVisible(): boolean;
  46600. /**
  46601. * Hide the inspector and close its window.
  46602. */
  46603. hide(): void;
  46604. /**
  46605. * Launch the debugLayer.
  46606. * @param config Define the configuration of the inspector
  46607. * @return a promise fulfilled when the debug layer is visible
  46608. */
  46609. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46610. }
  46611. }
  46612. declare module BABYLON {
  46613. /**
  46614. * Class containing static functions to help procedurally build meshes
  46615. */
  46616. export class BoxBuilder {
  46617. /**
  46618. * Creates a box mesh
  46619. * * The parameter `size` sets the size (float) of each box side (default 1)
  46620. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46621. * * 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)
  46622. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46624. * * 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
  46625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46626. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46627. * @param name defines the name of the mesh
  46628. * @param options defines the options used to create the mesh
  46629. * @param scene defines the hosting scene
  46630. * @returns the box mesh
  46631. */
  46632. static CreateBox(name: string, options: {
  46633. size?: number;
  46634. width?: number;
  46635. height?: number;
  46636. depth?: number;
  46637. faceUV?: Vector4[];
  46638. faceColors?: Color4[];
  46639. sideOrientation?: number;
  46640. frontUVs?: Vector4;
  46641. backUVs?: Vector4;
  46642. wrap?: boolean;
  46643. topBaseAt?: number;
  46644. bottomBaseAt?: number;
  46645. updatable?: boolean;
  46646. }, scene?: Nullable<Scene>): Mesh;
  46647. }
  46648. }
  46649. declare module BABYLON.Debug {
  46650. /**
  46651. * Used to show the physics impostor around the specific mesh
  46652. */
  46653. export class PhysicsViewer {
  46654. /** @hidden */
  46655. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46656. /** @hidden */
  46657. protected _meshes: Array<Nullable<AbstractMesh>>;
  46658. /** @hidden */
  46659. protected _scene: Nullable<Scene>;
  46660. /** @hidden */
  46661. protected _numMeshes: number;
  46662. /** @hidden */
  46663. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46664. private _renderFunction;
  46665. private _utilityLayer;
  46666. private _debugBoxMesh;
  46667. private _debugSphereMesh;
  46668. private _debugCylinderMesh;
  46669. private _debugMaterial;
  46670. private _debugMeshMeshes;
  46671. /**
  46672. * Creates a new PhysicsViewer
  46673. * @param scene defines the hosting scene
  46674. */
  46675. constructor(scene: Scene);
  46676. /** @hidden */
  46677. protected _updateDebugMeshes(): void;
  46678. /**
  46679. * Renders a specified physic impostor
  46680. * @param impostor defines the impostor to render
  46681. * @param targetMesh defines the mesh represented by the impostor
  46682. * @returns the new debug mesh used to render the impostor
  46683. */
  46684. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46685. /**
  46686. * Hides a specified physic impostor
  46687. * @param impostor defines the impostor to hide
  46688. */
  46689. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46690. private _getDebugMaterial;
  46691. private _getDebugBoxMesh;
  46692. private _getDebugSphereMesh;
  46693. private _getDebugCylinderMesh;
  46694. private _getDebugMeshMesh;
  46695. private _getDebugMesh;
  46696. /** Releases all resources */
  46697. dispose(): void;
  46698. }
  46699. }
  46700. declare module BABYLON {
  46701. /**
  46702. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46703. * in order to better appreciate the issue one might have.
  46704. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46705. */
  46706. export class RayHelper {
  46707. /**
  46708. * Defines the ray we are currently tryin to visualize.
  46709. */
  46710. ray: Nullable<Ray>;
  46711. private _renderPoints;
  46712. private _renderLine;
  46713. private _renderFunction;
  46714. private _scene;
  46715. private _updateToMeshFunction;
  46716. private _attachedToMesh;
  46717. private _meshSpaceDirection;
  46718. private _meshSpaceOrigin;
  46719. /**
  46720. * Helper function to create a colored helper in a scene in one line.
  46721. * @param ray Defines the ray we are currently tryin to visualize
  46722. * @param scene Defines the scene the ray is used in
  46723. * @param color Defines the color we want to see the ray in
  46724. * @returns The newly created ray helper.
  46725. */
  46726. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46727. /**
  46728. * Instantiate a new ray helper.
  46729. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46730. * in order to better appreciate the issue one might have.
  46731. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46732. * @param ray Defines the ray we are currently tryin to visualize
  46733. */
  46734. constructor(ray: Ray);
  46735. /**
  46736. * Shows the ray we are willing to debug.
  46737. * @param scene Defines the scene the ray needs to be rendered in
  46738. * @param color Defines the color the ray needs to be rendered in
  46739. */
  46740. show(scene: Scene, color?: Color3): void;
  46741. /**
  46742. * Hides the ray we are debugging.
  46743. */
  46744. hide(): void;
  46745. private _render;
  46746. /**
  46747. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46748. * @param mesh Defines the mesh we want the helper attached to
  46749. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46750. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46751. * @param length Defines the length of the ray
  46752. */
  46753. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46754. /**
  46755. * Detach the ray helper from the mesh it has previously been attached to.
  46756. */
  46757. detachFromMesh(): void;
  46758. private _updateToMesh;
  46759. /**
  46760. * Dispose the helper and release its associated resources.
  46761. */
  46762. dispose(): void;
  46763. }
  46764. }
  46765. declare module BABYLON.Debug {
  46766. /**
  46767. * Class used to render a debug view of a given skeleton
  46768. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46769. */
  46770. export class SkeletonViewer {
  46771. /** defines the skeleton to render */
  46772. skeleton: Skeleton;
  46773. /** defines the mesh attached to the skeleton */
  46774. mesh: AbstractMesh;
  46775. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46776. autoUpdateBonesMatrices: boolean;
  46777. /** defines the rendering group id to use with the viewer */
  46778. renderingGroupId: number;
  46779. /** Gets or sets the color used to render the skeleton */
  46780. color: Color3;
  46781. private _scene;
  46782. private _debugLines;
  46783. private _debugMesh;
  46784. private _isEnabled;
  46785. private _renderFunction;
  46786. private _utilityLayer;
  46787. /**
  46788. * Returns the mesh used to render the bones
  46789. */
  46790. get debugMesh(): Nullable<LinesMesh>;
  46791. /**
  46792. * Creates a new SkeletonViewer
  46793. * @param skeleton defines the skeleton to render
  46794. * @param mesh defines the mesh attached to the skeleton
  46795. * @param scene defines the hosting scene
  46796. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46797. * @param renderingGroupId defines the rendering group id to use with the viewer
  46798. */
  46799. constructor(
  46800. /** defines the skeleton to render */
  46801. skeleton: Skeleton,
  46802. /** defines the mesh attached to the skeleton */
  46803. mesh: AbstractMesh, scene: Scene,
  46804. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46805. autoUpdateBonesMatrices?: boolean,
  46806. /** defines the rendering group id to use with the viewer */
  46807. renderingGroupId?: number);
  46808. /** Gets or sets a boolean indicating if the viewer is enabled */
  46809. set isEnabled(value: boolean);
  46810. get isEnabled(): boolean;
  46811. private _getBonePosition;
  46812. private _getLinesForBonesWithLength;
  46813. private _getLinesForBonesNoLength;
  46814. /** Update the viewer to sync with current skeleton state */
  46815. update(): void;
  46816. /** Release associated resources */
  46817. dispose(): void;
  46818. }
  46819. }
  46820. declare module BABYLON {
  46821. /**
  46822. * Options to create the null engine
  46823. */
  46824. export class NullEngineOptions {
  46825. /**
  46826. * Render width (Default: 512)
  46827. */
  46828. renderWidth: number;
  46829. /**
  46830. * Render height (Default: 256)
  46831. */
  46832. renderHeight: number;
  46833. /**
  46834. * Texture size (Default: 512)
  46835. */
  46836. textureSize: number;
  46837. /**
  46838. * If delta time between frames should be constant
  46839. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46840. */
  46841. deterministicLockstep: boolean;
  46842. /**
  46843. * Maximum about of steps between frames (Default: 4)
  46844. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46845. */
  46846. lockstepMaxSteps: number;
  46847. }
  46848. /**
  46849. * The null engine class provides support for headless version of babylon.js.
  46850. * This can be used in server side scenario or for testing purposes
  46851. */
  46852. export class NullEngine extends Engine {
  46853. private _options;
  46854. /**
  46855. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46856. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46857. * @returns true if engine is in deterministic lock step mode
  46858. */
  46859. isDeterministicLockStep(): boolean;
  46860. /**
  46861. * Gets the max steps when engine is running in deterministic lock step
  46862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46863. * @returns the max steps
  46864. */
  46865. getLockstepMaxSteps(): number;
  46866. /**
  46867. * Gets the current hardware scaling level.
  46868. * By default the hardware scaling level is computed from the window device ratio.
  46869. * 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.
  46870. * @returns a number indicating the current hardware scaling level
  46871. */
  46872. getHardwareScalingLevel(): number;
  46873. constructor(options?: NullEngineOptions);
  46874. /**
  46875. * Creates a vertex buffer
  46876. * @param vertices the data for the vertex buffer
  46877. * @returns the new WebGL static buffer
  46878. */
  46879. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46880. /**
  46881. * Creates a new index buffer
  46882. * @param indices defines the content of the index buffer
  46883. * @param updatable defines if the index buffer must be updatable
  46884. * @returns a new webGL buffer
  46885. */
  46886. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46887. /**
  46888. * Clear the current render buffer or the current render target (if any is set up)
  46889. * @param color defines the color to use
  46890. * @param backBuffer defines if the back buffer must be cleared
  46891. * @param depth defines if the depth buffer must be cleared
  46892. * @param stencil defines if the stencil buffer must be cleared
  46893. */
  46894. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46895. /**
  46896. * Gets the current render width
  46897. * @param useScreen defines if screen size must be used (or the current render target if any)
  46898. * @returns a number defining the current render width
  46899. */
  46900. getRenderWidth(useScreen?: boolean): number;
  46901. /**
  46902. * Gets the current render height
  46903. * @param useScreen defines if screen size must be used (or the current render target if any)
  46904. * @returns a number defining the current render height
  46905. */
  46906. getRenderHeight(useScreen?: boolean): number;
  46907. /**
  46908. * Set the WebGL's viewport
  46909. * @param viewport defines the viewport element to be used
  46910. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46911. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46912. */
  46913. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46914. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46915. /**
  46916. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46917. * @param pipelineContext defines the pipeline context to use
  46918. * @param uniformsNames defines the list of uniform names
  46919. * @returns an array of webGL uniform locations
  46920. */
  46921. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46922. /**
  46923. * Gets the lsit of active attributes for a given webGL program
  46924. * @param pipelineContext defines the pipeline context to use
  46925. * @param attributesNames defines the list of attribute names to get
  46926. * @returns an array of indices indicating the offset of each attribute
  46927. */
  46928. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46929. /**
  46930. * Binds an effect to the webGL context
  46931. * @param effect defines the effect to bind
  46932. */
  46933. bindSamplers(effect: Effect): void;
  46934. /**
  46935. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46936. * @param effect defines the effect to activate
  46937. */
  46938. enableEffect(effect: Effect): void;
  46939. /**
  46940. * Set various states to the webGL context
  46941. * @param culling defines backface culling state
  46942. * @param zOffset defines the value to apply to zOffset (0 by default)
  46943. * @param force defines if states must be applied even if cache is up to date
  46944. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46945. */
  46946. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46947. /**
  46948. * Set the value of an uniform to an array of int32
  46949. * @param uniform defines the webGL uniform location where to store the value
  46950. * @param array defines the array of int32 to store
  46951. */
  46952. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46953. /**
  46954. * Set the value of an uniform to an array of int32 (stored as vec2)
  46955. * @param uniform defines the webGL uniform location where to store the value
  46956. * @param array defines the array of int32 to store
  46957. */
  46958. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46959. /**
  46960. * Set the value of an uniform to an array of int32 (stored as vec3)
  46961. * @param uniform defines the webGL uniform location where to store the value
  46962. * @param array defines the array of int32 to store
  46963. */
  46964. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46965. /**
  46966. * Set the value of an uniform to an array of int32 (stored as vec4)
  46967. * @param uniform defines the webGL uniform location where to store the value
  46968. * @param array defines the array of int32 to store
  46969. */
  46970. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46971. /**
  46972. * Set the value of an uniform to an array of float32
  46973. * @param uniform defines the webGL uniform location where to store the value
  46974. * @param array defines the array of float32 to store
  46975. */
  46976. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46977. /**
  46978. * Set the value of an uniform to an array of float32 (stored as vec2)
  46979. * @param uniform defines the webGL uniform location where to store the value
  46980. * @param array defines the array of float32 to store
  46981. */
  46982. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46983. /**
  46984. * Set the value of an uniform to an array of float32 (stored as vec3)
  46985. * @param uniform defines the webGL uniform location where to store the value
  46986. * @param array defines the array of float32 to store
  46987. */
  46988. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46989. /**
  46990. * Set the value of an uniform to an array of float32 (stored as vec4)
  46991. * @param uniform defines the webGL uniform location where to store the value
  46992. * @param array defines the array of float32 to store
  46993. */
  46994. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46995. /**
  46996. * Set the value of an uniform to an array of number
  46997. * @param uniform defines the webGL uniform location where to store the value
  46998. * @param array defines the array of number to store
  46999. */
  47000. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47001. /**
  47002. * Set the value of an uniform to an array of number (stored as vec2)
  47003. * @param uniform defines the webGL uniform location where to store the value
  47004. * @param array defines the array of number to store
  47005. */
  47006. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47007. /**
  47008. * Set the value of an uniform to an array of number (stored as vec3)
  47009. * @param uniform defines the webGL uniform location where to store the value
  47010. * @param array defines the array of number to store
  47011. */
  47012. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47013. /**
  47014. * Set the value of an uniform to an array of number (stored as vec4)
  47015. * @param uniform defines the webGL uniform location where to store the value
  47016. * @param array defines the array of number to store
  47017. */
  47018. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47019. /**
  47020. * Set the value of an uniform to an array of float32 (stored as matrices)
  47021. * @param uniform defines the webGL uniform location where to store the value
  47022. * @param matrices defines the array of float32 to store
  47023. */
  47024. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47025. /**
  47026. * Set the value of an uniform to a matrix (3x3)
  47027. * @param uniform defines the webGL uniform location where to store the value
  47028. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47029. */
  47030. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47031. /**
  47032. * Set the value of an uniform to a matrix (2x2)
  47033. * @param uniform defines the webGL uniform location where to store the value
  47034. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47035. */
  47036. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47037. /**
  47038. * Set the value of an uniform to a number (float)
  47039. * @param uniform defines the webGL uniform location where to store the value
  47040. * @param value defines the float number to store
  47041. */
  47042. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47043. /**
  47044. * Set the value of an uniform to a vec2
  47045. * @param uniform defines the webGL uniform location where to store the value
  47046. * @param x defines the 1st component of the value
  47047. * @param y defines the 2nd component of the value
  47048. */
  47049. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47050. /**
  47051. * Set the value of an uniform to a vec3
  47052. * @param uniform defines the webGL uniform location where to store the value
  47053. * @param x defines the 1st component of the value
  47054. * @param y defines the 2nd component of the value
  47055. * @param z defines the 3rd component of the value
  47056. */
  47057. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47058. /**
  47059. * Set the value of an uniform to a boolean
  47060. * @param uniform defines the webGL uniform location where to store the value
  47061. * @param bool defines the boolean to store
  47062. */
  47063. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47064. /**
  47065. * Set the value of an uniform to a vec4
  47066. * @param uniform defines the webGL uniform location where to store the value
  47067. * @param x defines the 1st component of the value
  47068. * @param y defines the 2nd component of the value
  47069. * @param z defines the 3rd component of the value
  47070. * @param w defines the 4th component of the value
  47071. */
  47072. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47073. /**
  47074. * Sets the current alpha mode
  47075. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47076. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47077. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47078. */
  47079. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47080. /**
  47081. * Bind webGl buffers directly to the webGL context
  47082. * @param vertexBuffers defines the vertex buffer to bind
  47083. * @param indexBuffer defines the index buffer to bind
  47084. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47085. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47086. * @param effect defines the effect associated with the vertex buffer
  47087. */
  47088. bindBuffers(vertexBuffers: {
  47089. [key: string]: VertexBuffer;
  47090. }, indexBuffer: DataBuffer, effect: Effect): void;
  47091. /**
  47092. * Force the entire cache to be cleared
  47093. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47094. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47095. */
  47096. wipeCaches(bruteForce?: boolean): void;
  47097. /**
  47098. * Send a draw order
  47099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47100. * @param indexStart defines the starting index
  47101. * @param indexCount defines the number of index to draw
  47102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47103. */
  47104. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47105. /**
  47106. * Draw a list of indexed primitives
  47107. * @param fillMode defines the primitive to use
  47108. * @param indexStart defines the starting index
  47109. * @param indexCount defines the number of index to draw
  47110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47111. */
  47112. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47113. /**
  47114. * Draw a list of unindexed primitives
  47115. * @param fillMode defines the primitive to use
  47116. * @param verticesStart defines the index of first vertex to draw
  47117. * @param verticesCount defines the count of vertices to draw
  47118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47119. */
  47120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47121. /** @hidden */
  47122. _createTexture(): WebGLTexture;
  47123. /** @hidden */
  47124. _releaseTexture(texture: InternalTexture): void;
  47125. /**
  47126. * Usually called from Texture.ts.
  47127. * Passed information to create a WebGLTexture
  47128. * @param urlArg defines a value which contains one of the following:
  47129. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47130. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47131. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47132. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47133. * @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)
  47134. * @param scene needed for loading to the correct scene
  47135. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47136. * @param onLoad optional callback to be called upon successful completion
  47137. * @param onError optional callback to be called upon failure
  47138. * @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
  47139. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47140. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47141. * @param forcedExtension defines the extension to use to pick the right loader
  47142. * @param mimeType defines an optional mime type
  47143. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47144. */
  47145. 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>, mimeType?: string): InternalTexture;
  47146. /**
  47147. * Creates a new render target texture
  47148. * @param size defines the size of the texture
  47149. * @param options defines the options used to create the texture
  47150. * @returns a new render target texture stored in an InternalTexture
  47151. */
  47152. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47153. /**
  47154. * Update the sampling mode of a given texture
  47155. * @param samplingMode defines the required sampling mode
  47156. * @param texture defines the texture to update
  47157. */
  47158. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47159. /**
  47160. * Binds the frame buffer to the specified texture.
  47161. * @param texture The texture to render to or null for the default canvas
  47162. * @param faceIndex The face of the texture to render to in case of cube texture
  47163. * @param requiredWidth The width of the target to render to
  47164. * @param requiredHeight The height of the target to render to
  47165. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47166. * @param lodLevel defines le lod level to bind to the frame buffer
  47167. */
  47168. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47169. /**
  47170. * Unbind the current render target texture from the webGL context
  47171. * @param texture defines the render target texture to unbind
  47172. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47173. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47174. */
  47175. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47176. /**
  47177. * Creates a dynamic vertex buffer
  47178. * @param vertices the data for the dynamic vertex buffer
  47179. * @returns the new WebGL dynamic buffer
  47180. */
  47181. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47182. /**
  47183. * Update the content of a dynamic texture
  47184. * @param texture defines the texture to update
  47185. * @param canvas defines the canvas containing the source
  47186. * @param invertY defines if data must be stored with Y axis inverted
  47187. * @param premulAlpha defines if alpha is stored as premultiplied
  47188. * @param format defines the format of the data
  47189. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47190. */
  47191. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47192. /**
  47193. * Gets a boolean indicating if all created effects are ready
  47194. * @returns true if all effects are ready
  47195. */
  47196. areAllEffectsReady(): boolean;
  47197. /**
  47198. * @hidden
  47199. * Get the current error code of the webGL context
  47200. * @returns the error code
  47201. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47202. */
  47203. getError(): number;
  47204. /** @hidden */
  47205. _getUnpackAlignement(): number;
  47206. /** @hidden */
  47207. _unpackFlipY(value: boolean): void;
  47208. /**
  47209. * Update a dynamic index buffer
  47210. * @param indexBuffer defines the target index buffer
  47211. * @param indices defines the data to update
  47212. * @param offset defines the offset in the target index buffer where update should start
  47213. */
  47214. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47215. /**
  47216. * Updates a dynamic vertex buffer.
  47217. * @param vertexBuffer the vertex buffer to update
  47218. * @param vertices the data used to update the vertex buffer
  47219. * @param byteOffset the byte offset of the data (optional)
  47220. * @param byteLength the byte length of the data (optional)
  47221. */
  47222. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47223. /** @hidden */
  47224. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47225. /** @hidden */
  47226. _bindTexture(channel: number, texture: InternalTexture): void;
  47227. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47228. /**
  47229. * 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
  47230. */
  47231. releaseEffects(): void;
  47232. displayLoadingUI(): void;
  47233. hideLoadingUI(): void;
  47234. /** @hidden */
  47235. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47236. /** @hidden */
  47237. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47238. /** @hidden */
  47239. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47240. /** @hidden */
  47241. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47242. }
  47243. }
  47244. declare module BABYLON {
  47245. /**
  47246. * @hidden
  47247. **/
  47248. export class _TimeToken {
  47249. _startTimeQuery: Nullable<WebGLQuery>;
  47250. _endTimeQuery: Nullable<WebGLQuery>;
  47251. _timeElapsedQuery: Nullable<WebGLQuery>;
  47252. _timeElapsedQueryEnded: boolean;
  47253. }
  47254. }
  47255. declare module BABYLON {
  47256. /** @hidden */
  47257. export class _OcclusionDataStorage {
  47258. /** @hidden */
  47259. occlusionInternalRetryCounter: number;
  47260. /** @hidden */
  47261. isOcclusionQueryInProgress: boolean;
  47262. /** @hidden */
  47263. isOccluded: boolean;
  47264. /** @hidden */
  47265. occlusionRetryCount: number;
  47266. /** @hidden */
  47267. occlusionType: number;
  47268. /** @hidden */
  47269. occlusionQueryAlgorithmType: number;
  47270. }
  47271. interface Engine {
  47272. /**
  47273. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47274. * @return the new query
  47275. */
  47276. createQuery(): WebGLQuery;
  47277. /**
  47278. * Delete and release a webGL query
  47279. * @param query defines the query to delete
  47280. * @return the current engine
  47281. */
  47282. deleteQuery(query: WebGLQuery): Engine;
  47283. /**
  47284. * Check if a given query has resolved and got its value
  47285. * @param query defines the query to check
  47286. * @returns true if the query got its value
  47287. */
  47288. isQueryResultAvailable(query: WebGLQuery): boolean;
  47289. /**
  47290. * Gets the value of a given query
  47291. * @param query defines the query to check
  47292. * @returns the value of the query
  47293. */
  47294. getQueryResult(query: WebGLQuery): number;
  47295. /**
  47296. * Initiates an occlusion query
  47297. * @param algorithmType defines the algorithm to use
  47298. * @param query defines the query to use
  47299. * @returns the current engine
  47300. * @see http://doc.babylonjs.com/features/occlusionquery
  47301. */
  47302. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47303. /**
  47304. * Ends an occlusion query
  47305. * @see http://doc.babylonjs.com/features/occlusionquery
  47306. * @param algorithmType defines the algorithm to use
  47307. * @returns the current engine
  47308. */
  47309. endOcclusionQuery(algorithmType: number): Engine;
  47310. /**
  47311. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47312. * Please note that only one query can be issued at a time
  47313. * @returns a time token used to track the time span
  47314. */
  47315. startTimeQuery(): Nullable<_TimeToken>;
  47316. /**
  47317. * Ends a time query
  47318. * @param token defines the token used to measure the time span
  47319. * @returns the time spent (in ns)
  47320. */
  47321. endTimeQuery(token: _TimeToken): int;
  47322. /** @hidden */
  47323. _currentNonTimestampToken: Nullable<_TimeToken>;
  47324. /** @hidden */
  47325. _createTimeQuery(): WebGLQuery;
  47326. /** @hidden */
  47327. _deleteTimeQuery(query: WebGLQuery): void;
  47328. /** @hidden */
  47329. _getGlAlgorithmType(algorithmType: number): number;
  47330. /** @hidden */
  47331. _getTimeQueryResult(query: WebGLQuery): any;
  47332. /** @hidden */
  47333. _getTimeQueryAvailability(query: WebGLQuery): any;
  47334. }
  47335. interface AbstractMesh {
  47336. /**
  47337. * Backing filed
  47338. * @hidden
  47339. */
  47340. __occlusionDataStorage: _OcclusionDataStorage;
  47341. /**
  47342. * Access property
  47343. * @hidden
  47344. */
  47345. _occlusionDataStorage: _OcclusionDataStorage;
  47346. /**
  47347. * 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.
  47348. * The default value is -1 which means don't break the query and wait till the result
  47349. * @see http://doc.babylonjs.com/features/occlusionquery
  47350. */
  47351. occlusionRetryCount: number;
  47352. /**
  47353. * 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:
  47354. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47355. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47356. * * 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.
  47357. * @see http://doc.babylonjs.com/features/occlusionquery
  47358. */
  47359. occlusionType: number;
  47360. /**
  47361. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47362. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47363. * * 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.
  47364. * @see http://doc.babylonjs.com/features/occlusionquery
  47365. */
  47366. occlusionQueryAlgorithmType: number;
  47367. /**
  47368. * 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
  47369. * @see http://doc.babylonjs.com/features/occlusionquery
  47370. */
  47371. isOccluded: boolean;
  47372. /**
  47373. * Flag to check the progress status of the query
  47374. * @see http://doc.babylonjs.com/features/occlusionquery
  47375. */
  47376. isOcclusionQueryInProgress: boolean;
  47377. }
  47378. }
  47379. declare module BABYLON {
  47380. /** @hidden */
  47381. export var _forceTransformFeedbackToBundle: boolean;
  47382. interface Engine {
  47383. /**
  47384. * Creates a webGL transform feedback object
  47385. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47386. * @returns the webGL transform feedback object
  47387. */
  47388. createTransformFeedback(): WebGLTransformFeedback;
  47389. /**
  47390. * Delete a webGL transform feedback object
  47391. * @param value defines the webGL transform feedback object to delete
  47392. */
  47393. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47394. /**
  47395. * Bind a webGL transform feedback object to the webgl context
  47396. * @param value defines the webGL transform feedback object to bind
  47397. */
  47398. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47399. /**
  47400. * Begins a transform feedback operation
  47401. * @param usePoints defines if points or triangles must be used
  47402. */
  47403. beginTransformFeedback(usePoints: boolean): void;
  47404. /**
  47405. * Ends a transform feedback operation
  47406. */
  47407. endTransformFeedback(): void;
  47408. /**
  47409. * Specify the varyings to use with transform feedback
  47410. * @param program defines the associated webGL program
  47411. * @param value defines the list of strings representing the varying names
  47412. */
  47413. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47414. /**
  47415. * Bind a webGL buffer for a transform feedback operation
  47416. * @param value defines the webGL buffer to bind
  47417. */
  47418. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47419. }
  47420. }
  47421. declare module BABYLON {
  47422. /**
  47423. * Creation options of the multi render target texture.
  47424. */
  47425. export interface IMultiRenderTargetOptions {
  47426. /**
  47427. * Define if the texture needs to create mip maps after render.
  47428. */
  47429. generateMipMaps?: boolean;
  47430. /**
  47431. * Define the types of all the draw buffers we want to create
  47432. */
  47433. types?: number[];
  47434. /**
  47435. * Define the sampling modes of all the draw buffers we want to create
  47436. */
  47437. samplingModes?: number[];
  47438. /**
  47439. * Define if a depth buffer is required
  47440. */
  47441. generateDepthBuffer?: boolean;
  47442. /**
  47443. * Define if a stencil buffer is required
  47444. */
  47445. generateStencilBuffer?: boolean;
  47446. /**
  47447. * Define if a depth texture is required instead of a depth buffer
  47448. */
  47449. generateDepthTexture?: boolean;
  47450. /**
  47451. * Define the number of desired draw buffers
  47452. */
  47453. textureCount?: number;
  47454. /**
  47455. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47456. */
  47457. doNotChangeAspectRatio?: boolean;
  47458. /**
  47459. * Define the default type of the buffers we are creating
  47460. */
  47461. defaultType?: number;
  47462. }
  47463. /**
  47464. * A multi render target, like a render target provides the ability to render to a texture.
  47465. * Unlike the render target, it can render to several draw buffers in one draw.
  47466. * This is specially interesting in deferred rendering or for any effects requiring more than
  47467. * just one color from a single pass.
  47468. */
  47469. export class MultiRenderTarget extends RenderTargetTexture {
  47470. private _internalTextures;
  47471. private _textures;
  47472. private _multiRenderTargetOptions;
  47473. /**
  47474. * Get if draw buffers are currently supported by the used hardware and browser.
  47475. */
  47476. get isSupported(): boolean;
  47477. /**
  47478. * Get the list of textures generated by the multi render target.
  47479. */
  47480. get textures(): Texture[];
  47481. /**
  47482. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47483. */
  47484. get depthTexture(): Texture;
  47485. /**
  47486. * Set the wrapping mode on U of all the textures we are rendering to.
  47487. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47488. */
  47489. set wrapU(wrap: number);
  47490. /**
  47491. * Set the wrapping mode on V of all the textures we are rendering to.
  47492. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47493. */
  47494. set wrapV(wrap: number);
  47495. /**
  47496. * Instantiate a new multi render target texture.
  47497. * A multi render target, like a render target provides the ability to render to a texture.
  47498. * Unlike the render target, it can render to several draw buffers in one draw.
  47499. * This is specially interesting in deferred rendering or for any effects requiring more than
  47500. * just one color from a single pass.
  47501. * @param name Define the name of the texture
  47502. * @param size Define the size of the buffers to render to
  47503. * @param count Define the number of target we are rendering into
  47504. * @param scene Define the scene the texture belongs to
  47505. * @param options Define the options used to create the multi render target
  47506. */
  47507. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47508. /** @hidden */
  47509. _rebuild(): void;
  47510. private _createInternalTextures;
  47511. private _createTextures;
  47512. /**
  47513. * Define the number of samples used if MSAA is enabled.
  47514. */
  47515. get samples(): number;
  47516. set samples(value: number);
  47517. /**
  47518. * Resize all the textures in the multi render target.
  47519. * Be carrefull as it will recreate all the data in the new texture.
  47520. * @param size Define the new size
  47521. */
  47522. resize(size: any): void;
  47523. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47524. /**
  47525. * Dispose the render targets and their associated resources
  47526. */
  47527. dispose(): void;
  47528. /**
  47529. * Release all the underlying texture used as draw buffers.
  47530. */
  47531. releaseInternalTextures(): void;
  47532. }
  47533. }
  47534. declare module BABYLON {
  47535. interface ThinEngine {
  47536. /**
  47537. * Unbind a list of render target textures from the webGL context
  47538. * This is used only when drawBuffer extension or webGL2 are active
  47539. * @param textures defines the render target textures to unbind
  47540. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47541. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47542. */
  47543. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47544. /**
  47545. * Create a multi render target texture
  47546. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47547. * @param size defines the size of the texture
  47548. * @param options defines the creation options
  47549. * @returns the cube texture as an InternalTexture
  47550. */
  47551. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47552. /**
  47553. * Update the sample count for a given multiple render target texture
  47554. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47555. * @param textures defines the textures to update
  47556. * @param samples defines the sample count to set
  47557. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47558. */
  47559. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47560. }
  47561. }
  47562. declare module BABYLON {
  47563. /**
  47564. * Class used to define an additional view for the engine
  47565. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47566. */
  47567. export class EngineView {
  47568. /** Defines the canvas where to render the view */
  47569. target: HTMLCanvasElement;
  47570. /** Defines an optional camera used to render the view (will use active camera else) */
  47571. camera?: Camera;
  47572. }
  47573. interface Engine {
  47574. /**
  47575. * Gets or sets the HTML element to use for attaching events
  47576. */
  47577. inputElement: Nullable<HTMLElement>;
  47578. /**
  47579. * Gets the current engine view
  47580. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47581. */
  47582. activeView: Nullable<EngineView>;
  47583. /** Gets or sets the list of views */
  47584. views: EngineView[];
  47585. /**
  47586. * Register a new child canvas
  47587. * @param canvas defines the canvas to register
  47588. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47589. * @returns the associated view
  47590. */
  47591. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47592. /**
  47593. * Remove a registered child canvas
  47594. * @param canvas defines the canvas to remove
  47595. * @returns the current engine
  47596. */
  47597. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47598. }
  47599. }
  47600. declare module BABYLON {
  47601. interface Engine {
  47602. /** @hidden */
  47603. _excludedCompressedTextures: string[];
  47604. /** @hidden */
  47605. _textureFormatInUse: string;
  47606. /**
  47607. * Gets the list of texture formats supported
  47608. */
  47609. readonly texturesSupported: Array<string>;
  47610. /**
  47611. * Gets the texture format in use
  47612. */
  47613. readonly textureFormatInUse: Nullable<string>;
  47614. /**
  47615. * Set the compressed texture extensions or file names to skip.
  47616. *
  47617. * @param skippedFiles defines the list of those texture files you want to skip
  47618. * Example: [".dds", ".env", "myfile.png"]
  47619. */
  47620. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47621. /**
  47622. * Set the compressed texture format to use, based on the formats you have, and the formats
  47623. * supported by the hardware / browser.
  47624. *
  47625. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47626. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47627. * to API arguments needed to compressed textures. This puts the burden on the container
  47628. * generator to house the arcane code for determining these for current & future formats.
  47629. *
  47630. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47631. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47632. *
  47633. * Note: The result of this call is not taken into account when a texture is base64.
  47634. *
  47635. * @param formatsAvailable defines the list of those format families you have created
  47636. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47637. *
  47638. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47639. * @returns The extension selected.
  47640. */
  47641. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47642. }
  47643. }
  47644. declare module BABYLON {
  47645. /**
  47646. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47647. */
  47648. export interface CubeMapInfo {
  47649. /**
  47650. * The pixel array for the front face.
  47651. * This is stored in format, left to right, up to down format.
  47652. */
  47653. front: Nullable<ArrayBufferView>;
  47654. /**
  47655. * The pixel array for the back face.
  47656. * This is stored in format, left to right, up to down format.
  47657. */
  47658. back: Nullable<ArrayBufferView>;
  47659. /**
  47660. * The pixel array for the left face.
  47661. * This is stored in format, left to right, up to down format.
  47662. */
  47663. left: Nullable<ArrayBufferView>;
  47664. /**
  47665. * The pixel array for the right face.
  47666. * This is stored in format, left to right, up to down format.
  47667. */
  47668. right: Nullable<ArrayBufferView>;
  47669. /**
  47670. * The pixel array for the up face.
  47671. * This is stored in format, left to right, up to down format.
  47672. */
  47673. up: Nullable<ArrayBufferView>;
  47674. /**
  47675. * The pixel array for the down face.
  47676. * This is stored in format, left to right, up to down format.
  47677. */
  47678. down: Nullable<ArrayBufferView>;
  47679. /**
  47680. * The size of the cubemap stored.
  47681. *
  47682. * Each faces will be size * size pixels.
  47683. */
  47684. size: number;
  47685. /**
  47686. * The format of the texture.
  47687. *
  47688. * RGBA, RGB.
  47689. */
  47690. format: number;
  47691. /**
  47692. * The type of the texture data.
  47693. *
  47694. * UNSIGNED_INT, FLOAT.
  47695. */
  47696. type: number;
  47697. /**
  47698. * Specifies whether the texture is in gamma space.
  47699. */
  47700. gammaSpace: boolean;
  47701. }
  47702. /**
  47703. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47704. */
  47705. export class PanoramaToCubeMapTools {
  47706. private static FACE_FRONT;
  47707. private static FACE_BACK;
  47708. private static FACE_RIGHT;
  47709. private static FACE_LEFT;
  47710. private static FACE_DOWN;
  47711. private static FACE_UP;
  47712. /**
  47713. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47714. *
  47715. * @param float32Array The source data.
  47716. * @param inputWidth The width of the input panorama.
  47717. * @param inputHeight The height of the input panorama.
  47718. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47719. * @return The cubemap data
  47720. */
  47721. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47722. private static CreateCubemapTexture;
  47723. private static CalcProjectionSpherical;
  47724. }
  47725. }
  47726. declare module BABYLON {
  47727. /**
  47728. * Helper class dealing with the extraction of spherical polynomial dataArray
  47729. * from a cube map.
  47730. */
  47731. export class CubeMapToSphericalPolynomialTools {
  47732. private static FileFaces;
  47733. /**
  47734. * Converts a texture to the according Spherical Polynomial data.
  47735. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47736. *
  47737. * @param texture The texture to extract the information from.
  47738. * @return The Spherical Polynomial data.
  47739. */
  47740. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47741. /**
  47742. * Converts a cubemap to the according Spherical Polynomial data.
  47743. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47744. *
  47745. * @param cubeInfo The Cube map to extract the information from.
  47746. * @return The Spherical Polynomial data.
  47747. */
  47748. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47749. }
  47750. }
  47751. declare module BABYLON {
  47752. interface BaseTexture {
  47753. /**
  47754. * Get the polynomial representation of the texture data.
  47755. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47756. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47757. */
  47758. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47759. }
  47760. }
  47761. declare module BABYLON {
  47762. /** @hidden */
  47763. export var rgbdEncodePixelShader: {
  47764. name: string;
  47765. shader: string;
  47766. };
  47767. }
  47768. declare module BABYLON {
  47769. /** @hidden */
  47770. export var rgbdDecodePixelShader: {
  47771. name: string;
  47772. shader: string;
  47773. };
  47774. }
  47775. declare module BABYLON {
  47776. /**
  47777. * Raw texture data and descriptor sufficient for WebGL texture upload
  47778. */
  47779. export interface EnvironmentTextureInfo {
  47780. /**
  47781. * Version of the environment map
  47782. */
  47783. version: number;
  47784. /**
  47785. * Width of image
  47786. */
  47787. width: number;
  47788. /**
  47789. * Irradiance information stored in the file.
  47790. */
  47791. irradiance: any;
  47792. /**
  47793. * Specular information stored in the file.
  47794. */
  47795. specular: any;
  47796. }
  47797. /**
  47798. * Defines One Image in the file. It requires only the position in the file
  47799. * as well as the length.
  47800. */
  47801. interface BufferImageData {
  47802. /**
  47803. * Length of the image data.
  47804. */
  47805. length: number;
  47806. /**
  47807. * Position of the data from the null terminator delimiting the end of the JSON.
  47808. */
  47809. position: number;
  47810. }
  47811. /**
  47812. * Defines the specular data enclosed in the file.
  47813. * This corresponds to the version 1 of the data.
  47814. */
  47815. export interface EnvironmentTextureSpecularInfoV1 {
  47816. /**
  47817. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47818. */
  47819. specularDataPosition?: number;
  47820. /**
  47821. * This contains all the images data needed to reconstruct the cubemap.
  47822. */
  47823. mipmaps: Array<BufferImageData>;
  47824. /**
  47825. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47826. */
  47827. lodGenerationScale: number;
  47828. }
  47829. /**
  47830. * Sets of helpers addressing the serialization and deserialization of environment texture
  47831. * stored in a BabylonJS env file.
  47832. * Those files are usually stored as .env files.
  47833. */
  47834. export class EnvironmentTextureTools {
  47835. /**
  47836. * Magic number identifying the env file.
  47837. */
  47838. private static _MagicBytes;
  47839. /**
  47840. * Gets the environment info from an env file.
  47841. * @param data The array buffer containing the .env bytes.
  47842. * @returns the environment file info (the json header) if successfully parsed.
  47843. */
  47844. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47845. /**
  47846. * Creates an environment texture from a loaded cube texture.
  47847. * @param texture defines the cube texture to convert in env file
  47848. * @return a promise containing the environment data if succesfull.
  47849. */
  47850. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47851. /**
  47852. * Creates a JSON representation of the spherical data.
  47853. * @param texture defines the texture containing the polynomials
  47854. * @return the JSON representation of the spherical info
  47855. */
  47856. private static _CreateEnvTextureIrradiance;
  47857. /**
  47858. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47859. * @param data the image data
  47860. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47861. * @return the views described by info providing access to the underlying buffer
  47862. */
  47863. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47864. /**
  47865. * Uploads the texture info contained in the env file to the GPU.
  47866. * @param texture defines the internal texture to upload to
  47867. * @param data defines the data to load
  47868. * @param info defines the texture info retrieved through the GetEnvInfo method
  47869. * @returns a promise
  47870. */
  47871. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47872. private static _OnImageReadyAsync;
  47873. /**
  47874. * Uploads the levels of image data to the GPU.
  47875. * @param texture defines the internal texture to upload to
  47876. * @param imageData defines the array buffer views of image data [mipmap][face]
  47877. * @returns a promise
  47878. */
  47879. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47880. /**
  47881. * Uploads spherical polynomials information to the texture.
  47882. * @param texture defines the texture we are trying to upload the information to
  47883. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47884. */
  47885. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47886. /** @hidden */
  47887. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47888. }
  47889. }
  47890. declare module BABYLON {
  47891. /**
  47892. * Contains position and normal vectors for a vertex
  47893. */
  47894. export class PositionNormalVertex {
  47895. /** the position of the vertex (defaut: 0,0,0) */
  47896. position: Vector3;
  47897. /** the normal of the vertex (defaut: 0,1,0) */
  47898. normal: Vector3;
  47899. /**
  47900. * Creates a PositionNormalVertex
  47901. * @param position the position of the vertex (defaut: 0,0,0)
  47902. * @param normal the normal of the vertex (defaut: 0,1,0)
  47903. */
  47904. constructor(
  47905. /** the position of the vertex (defaut: 0,0,0) */
  47906. position?: Vector3,
  47907. /** the normal of the vertex (defaut: 0,1,0) */
  47908. normal?: Vector3);
  47909. /**
  47910. * Clones the PositionNormalVertex
  47911. * @returns the cloned PositionNormalVertex
  47912. */
  47913. clone(): PositionNormalVertex;
  47914. }
  47915. /**
  47916. * Contains position, normal and uv vectors for a vertex
  47917. */
  47918. export class PositionNormalTextureVertex {
  47919. /** the position of the vertex (defaut: 0,0,0) */
  47920. position: Vector3;
  47921. /** the normal of the vertex (defaut: 0,1,0) */
  47922. normal: Vector3;
  47923. /** the uv of the vertex (default: 0,0) */
  47924. uv: Vector2;
  47925. /**
  47926. * Creates a PositionNormalTextureVertex
  47927. * @param position the position of the vertex (defaut: 0,0,0)
  47928. * @param normal the normal of the vertex (defaut: 0,1,0)
  47929. * @param uv the uv of the vertex (default: 0,0)
  47930. */
  47931. constructor(
  47932. /** the position of the vertex (defaut: 0,0,0) */
  47933. position?: Vector3,
  47934. /** the normal of the vertex (defaut: 0,1,0) */
  47935. normal?: Vector3,
  47936. /** the uv of the vertex (default: 0,0) */
  47937. uv?: Vector2);
  47938. /**
  47939. * Clones the PositionNormalTextureVertex
  47940. * @returns the cloned PositionNormalTextureVertex
  47941. */
  47942. clone(): PositionNormalTextureVertex;
  47943. }
  47944. }
  47945. declare module BABYLON {
  47946. /** @hidden */
  47947. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47948. private _genericAttributeLocation;
  47949. private _varyingLocationCount;
  47950. private _varyingLocationMap;
  47951. private _replacements;
  47952. private _textureCount;
  47953. private _uniforms;
  47954. lineProcessor(line: string): string;
  47955. attributeProcessor(attribute: string): string;
  47956. varyingProcessor(varying: string, isFragment: boolean): string;
  47957. uniformProcessor(uniform: string): string;
  47958. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47959. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47960. }
  47961. }
  47962. declare module BABYLON {
  47963. /**
  47964. * Container for accessors for natively-stored mesh data buffers.
  47965. */
  47966. class NativeDataBuffer extends DataBuffer {
  47967. /**
  47968. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47969. */
  47970. nativeIndexBuffer?: any;
  47971. /**
  47972. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47973. */
  47974. nativeVertexBuffer?: any;
  47975. }
  47976. /** @hidden */
  47977. class NativeTexture extends InternalTexture {
  47978. getInternalTexture(): InternalTexture;
  47979. getViewCount(): number;
  47980. }
  47981. /** @hidden */
  47982. export class NativeEngine extends Engine {
  47983. private readonly _native;
  47984. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47985. private readonly INVALID_HANDLE;
  47986. getHardwareScalingLevel(): number;
  47987. constructor();
  47988. /**
  47989. * Can be used to override the current requestAnimationFrame requester.
  47990. * @hidden
  47991. */
  47992. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47993. /**
  47994. * Override default engine behavior.
  47995. * @param color
  47996. * @param backBuffer
  47997. * @param depth
  47998. * @param stencil
  47999. */
  48000. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48001. /**
  48002. * Gets host document
  48003. * @returns the host document object
  48004. */
  48005. getHostDocument(): Nullable<Document>;
  48006. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48007. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48008. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48009. recordVertexArrayObject(vertexBuffers: {
  48010. [key: string]: VertexBuffer;
  48011. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48012. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48013. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48014. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48015. /**
  48016. * Draw a list of indexed primitives
  48017. * @param fillMode defines the primitive to use
  48018. * @param indexStart defines the starting index
  48019. * @param indexCount defines the number of index to draw
  48020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48021. */
  48022. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48023. /**
  48024. * Draw a list of unindexed primitives
  48025. * @param fillMode defines the primitive to use
  48026. * @param verticesStart defines the index of first vertex to draw
  48027. * @param verticesCount defines the count of vertices to draw
  48028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48029. */
  48030. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48031. createPipelineContext(): IPipelineContext;
  48032. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48033. /** @hidden */
  48034. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48035. /** @hidden */
  48036. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48037. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48038. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48039. protected _setProgram(program: WebGLProgram): void;
  48040. _releaseEffect(effect: Effect): void;
  48041. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48042. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48043. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48044. bindSamplers(effect: Effect): void;
  48045. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48046. getRenderWidth(useScreen?: boolean): number;
  48047. getRenderHeight(useScreen?: boolean): number;
  48048. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48049. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48050. /**
  48051. * Set the z offset to apply to current rendering
  48052. * @param value defines the offset to apply
  48053. */
  48054. setZOffset(value: number): void;
  48055. /**
  48056. * Gets the current value of the zOffset
  48057. * @returns the current zOffset state
  48058. */
  48059. getZOffset(): number;
  48060. /**
  48061. * Enable or disable depth buffering
  48062. * @param enable defines the state to set
  48063. */
  48064. setDepthBuffer(enable: boolean): void;
  48065. /**
  48066. * Gets a boolean indicating if depth writing is enabled
  48067. * @returns the current depth writing state
  48068. */
  48069. getDepthWrite(): boolean;
  48070. /**
  48071. * Enable or disable depth writing
  48072. * @param enable defines the state to set
  48073. */
  48074. setDepthWrite(enable: boolean): void;
  48075. /**
  48076. * Enable or disable color writing
  48077. * @param enable defines the state to set
  48078. */
  48079. setColorWrite(enable: boolean): void;
  48080. /**
  48081. * Gets a boolean indicating if color writing is enabled
  48082. * @returns the current color writing state
  48083. */
  48084. getColorWrite(): boolean;
  48085. /**
  48086. * Sets alpha constants used by some alpha blending modes
  48087. * @param r defines the red component
  48088. * @param g defines the green component
  48089. * @param b defines the blue component
  48090. * @param a defines the alpha component
  48091. */
  48092. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48093. /**
  48094. * Sets the current alpha mode
  48095. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48096. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48097. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48098. */
  48099. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48100. /**
  48101. * Gets the current alpha mode
  48102. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48103. * @returns the current alpha mode
  48104. */
  48105. getAlphaMode(): number;
  48106. setInt(uniform: WebGLUniformLocation, int: number): void;
  48107. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48108. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48109. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48110. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48111. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48112. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48113. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48114. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48115. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48116. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48117. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48118. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48119. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48120. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48121. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48122. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48123. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48124. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48125. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48126. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48127. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48128. wipeCaches(bruteForce?: boolean): void;
  48129. _createTexture(): WebGLTexture;
  48130. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48131. /**
  48132. * Usually called from Texture.ts.
  48133. * Passed information to create a WebGLTexture
  48134. * @param urlArg defines a value which contains one of the following:
  48135. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48136. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48137. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48138. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48139. * @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)
  48140. * @param scene needed for loading to the correct scene
  48141. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48142. * @param onLoad optional callback to be called upon successful completion
  48143. * @param onError optional callback to be called upon failure
  48144. * @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
  48145. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48146. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48147. * @param forcedExtension defines the extension to use to pick the right loader
  48148. * @param mimeType defines an optional mime type
  48149. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48150. */
  48151. 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>, mimeType?: string): InternalTexture;
  48152. /**
  48153. * Creates a cube texture
  48154. * @param rootUrl defines the url where the files to load is located
  48155. * @param scene defines the current scene
  48156. * @param files defines the list of files to load (1 per face)
  48157. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48158. * @param onLoad defines an optional callback raised when the texture is loaded
  48159. * @param onError defines an optional callback raised if there is an issue to load the texture
  48160. * @param format defines the format of the data
  48161. * @param forcedExtension defines the extension to use to pick the right loader
  48162. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48163. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48164. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48165. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48166. * @returns the cube texture as an InternalTexture
  48167. */
  48168. 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;
  48169. private _getSamplingFilter;
  48170. private static _GetNativeTextureFormat;
  48171. createRenderTargetTexture(size: number | {
  48172. width: number;
  48173. height: number;
  48174. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48175. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48176. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48177. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48178. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48179. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48180. /**
  48181. * Updates a dynamic vertex buffer.
  48182. * @param vertexBuffer the vertex buffer to update
  48183. * @param data the data used to update the vertex buffer
  48184. * @param byteOffset the byte offset of the data (optional)
  48185. * @param byteLength the byte length of the data (optional)
  48186. */
  48187. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48188. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48189. private _updateAnisotropicLevel;
  48190. private _getAddressMode;
  48191. /** @hidden */
  48192. _bindTexture(channel: number, texture: InternalTexture): void;
  48193. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48194. releaseEffects(): void;
  48195. /** @hidden */
  48196. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48197. /** @hidden */
  48198. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48199. /** @hidden */
  48200. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48201. /** @hidden */
  48202. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48203. }
  48204. }
  48205. declare module BABYLON {
  48206. /**
  48207. * Gather the list of clipboard event types as constants.
  48208. */
  48209. export class ClipboardEventTypes {
  48210. /**
  48211. * The clipboard event is fired when a copy command is active (pressed).
  48212. */
  48213. static readonly COPY: number;
  48214. /**
  48215. * The clipboard event is fired when a cut command is active (pressed).
  48216. */
  48217. static readonly CUT: number;
  48218. /**
  48219. * The clipboard event is fired when a paste command is active (pressed).
  48220. */
  48221. static readonly PASTE: number;
  48222. }
  48223. /**
  48224. * This class is used to store clipboard related info for the onClipboardObservable event.
  48225. */
  48226. export class ClipboardInfo {
  48227. /**
  48228. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48229. */
  48230. type: number;
  48231. /**
  48232. * Defines the related dom event
  48233. */
  48234. event: ClipboardEvent;
  48235. /**
  48236. *Creates an instance of ClipboardInfo.
  48237. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48238. * @param event Defines the related dom event
  48239. */
  48240. constructor(
  48241. /**
  48242. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48243. */
  48244. type: number,
  48245. /**
  48246. * Defines the related dom event
  48247. */
  48248. event: ClipboardEvent);
  48249. /**
  48250. * Get the clipboard event's type from the keycode.
  48251. * @param keyCode Defines the keyCode for the current keyboard event.
  48252. * @return {number}
  48253. */
  48254. static GetTypeFromCharacter(keyCode: number): number;
  48255. }
  48256. }
  48257. declare module BABYLON {
  48258. /**
  48259. * Google Daydream controller
  48260. */
  48261. export class DaydreamController extends WebVRController {
  48262. /**
  48263. * Base Url for the controller model.
  48264. */
  48265. static MODEL_BASE_URL: string;
  48266. /**
  48267. * File name for the controller model.
  48268. */
  48269. static MODEL_FILENAME: string;
  48270. /**
  48271. * Gamepad Id prefix used to identify Daydream Controller.
  48272. */
  48273. static readonly GAMEPAD_ID_PREFIX: string;
  48274. /**
  48275. * Creates a new DaydreamController from a gamepad
  48276. * @param vrGamepad the gamepad that the controller should be created from
  48277. */
  48278. constructor(vrGamepad: any);
  48279. /**
  48280. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48281. * @param scene scene in which to add meshes
  48282. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48283. */
  48284. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48285. /**
  48286. * Called once for each button that changed state since the last frame
  48287. * @param buttonIdx Which button index changed
  48288. * @param state New state of the button
  48289. * @param changes Which properties on the state changed since last frame
  48290. */
  48291. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48292. }
  48293. }
  48294. declare module BABYLON {
  48295. /**
  48296. * Gear VR Controller
  48297. */
  48298. export class GearVRController extends WebVRController {
  48299. /**
  48300. * Base Url for the controller model.
  48301. */
  48302. static MODEL_BASE_URL: string;
  48303. /**
  48304. * File name for the controller model.
  48305. */
  48306. static MODEL_FILENAME: string;
  48307. /**
  48308. * Gamepad Id prefix used to identify this controller.
  48309. */
  48310. static readonly GAMEPAD_ID_PREFIX: string;
  48311. private readonly _buttonIndexToObservableNameMap;
  48312. /**
  48313. * Creates a new GearVRController from a gamepad
  48314. * @param vrGamepad the gamepad that the controller should be created from
  48315. */
  48316. constructor(vrGamepad: any);
  48317. /**
  48318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48319. * @param scene scene in which to add meshes
  48320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48321. */
  48322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48323. /**
  48324. * Called once for each button that changed state since the last frame
  48325. * @param buttonIdx Which button index changed
  48326. * @param state New state of the button
  48327. * @param changes Which properties on the state changed since last frame
  48328. */
  48329. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48330. }
  48331. }
  48332. declare module BABYLON {
  48333. /**
  48334. * Generic Controller
  48335. */
  48336. export class GenericController extends WebVRController {
  48337. /**
  48338. * Base Url for the controller model.
  48339. */
  48340. static readonly MODEL_BASE_URL: string;
  48341. /**
  48342. * File name for the controller model.
  48343. */
  48344. static readonly MODEL_FILENAME: string;
  48345. /**
  48346. * Creates a new GenericController from a gamepad
  48347. * @param vrGamepad the gamepad that the controller should be created from
  48348. */
  48349. constructor(vrGamepad: any);
  48350. /**
  48351. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48352. * @param scene scene in which to add meshes
  48353. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48354. */
  48355. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48356. /**
  48357. * Called once for each button that changed state since the last frame
  48358. * @param buttonIdx Which button index changed
  48359. * @param state New state of the button
  48360. * @param changes Which properties on the state changed since last frame
  48361. */
  48362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48363. }
  48364. }
  48365. declare module BABYLON {
  48366. /**
  48367. * Oculus Touch Controller
  48368. */
  48369. export class OculusTouchController extends WebVRController {
  48370. /**
  48371. * Base Url for the controller model.
  48372. */
  48373. static MODEL_BASE_URL: string;
  48374. /**
  48375. * File name for the left controller model.
  48376. */
  48377. static MODEL_LEFT_FILENAME: string;
  48378. /**
  48379. * File name for the right controller model.
  48380. */
  48381. static MODEL_RIGHT_FILENAME: string;
  48382. /**
  48383. * Base Url for the Quest controller model.
  48384. */
  48385. static QUEST_MODEL_BASE_URL: string;
  48386. /**
  48387. * @hidden
  48388. * If the controllers are running on a device that needs the updated Quest controller models
  48389. */
  48390. static _IsQuest: boolean;
  48391. /**
  48392. * Fired when the secondary trigger on this controller is modified
  48393. */
  48394. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48395. /**
  48396. * Fired when the thumb rest on this controller is modified
  48397. */
  48398. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48399. /**
  48400. * Creates a new OculusTouchController from a gamepad
  48401. * @param vrGamepad the gamepad that the controller should be created from
  48402. */
  48403. constructor(vrGamepad: any);
  48404. /**
  48405. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48406. * @param scene scene in which to add meshes
  48407. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48408. */
  48409. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48410. /**
  48411. * Fired when the A button on this controller is modified
  48412. */
  48413. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48414. /**
  48415. * Fired when the B button on this controller is modified
  48416. */
  48417. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48418. /**
  48419. * Fired when the X button on this controller is modified
  48420. */
  48421. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48422. /**
  48423. * Fired when the Y button on this controller is modified
  48424. */
  48425. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48426. /**
  48427. * Called once for each button that changed state since the last frame
  48428. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48429. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48430. * 2) secondary trigger (same)
  48431. * 3) A (right) X (left), touch, pressed = value
  48432. * 4) B / Y
  48433. * 5) thumb rest
  48434. * @param buttonIdx Which button index changed
  48435. * @param state New state of the button
  48436. * @param changes Which properties on the state changed since last frame
  48437. */
  48438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48439. }
  48440. }
  48441. declare module BABYLON {
  48442. /**
  48443. * Vive Controller
  48444. */
  48445. export class ViveController extends WebVRController {
  48446. /**
  48447. * Base Url for the controller model.
  48448. */
  48449. static MODEL_BASE_URL: string;
  48450. /**
  48451. * File name for the controller model.
  48452. */
  48453. static MODEL_FILENAME: string;
  48454. /**
  48455. * Creates a new ViveController from a gamepad
  48456. * @param vrGamepad the gamepad that the controller should be created from
  48457. */
  48458. constructor(vrGamepad: any);
  48459. /**
  48460. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48461. * @param scene scene in which to add meshes
  48462. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48463. */
  48464. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48465. /**
  48466. * Fired when the left button on this controller is modified
  48467. */
  48468. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48469. /**
  48470. * Fired when the right button on this controller is modified
  48471. */
  48472. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48473. /**
  48474. * Fired when the menu button on this controller is modified
  48475. */
  48476. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48477. /**
  48478. * Called once for each button that changed state since the last frame
  48479. * Vive mapping:
  48480. * 0: touchpad
  48481. * 1: trigger
  48482. * 2: left AND right buttons
  48483. * 3: menu button
  48484. * @param buttonIdx Which button index changed
  48485. * @param state New state of the button
  48486. * @param changes Which properties on the state changed since last frame
  48487. */
  48488. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48489. }
  48490. }
  48491. declare module BABYLON {
  48492. /**
  48493. * Defines the WindowsMotionController object that the state of the windows motion controller
  48494. */
  48495. export class WindowsMotionController extends WebVRController {
  48496. /**
  48497. * The base url used to load the left and right controller models
  48498. */
  48499. static MODEL_BASE_URL: string;
  48500. /**
  48501. * The name of the left controller model file
  48502. */
  48503. static MODEL_LEFT_FILENAME: string;
  48504. /**
  48505. * The name of the right controller model file
  48506. */
  48507. static MODEL_RIGHT_FILENAME: string;
  48508. /**
  48509. * The controller name prefix for this controller type
  48510. */
  48511. static readonly GAMEPAD_ID_PREFIX: string;
  48512. /**
  48513. * The controller id pattern for this controller type
  48514. */
  48515. private static readonly GAMEPAD_ID_PATTERN;
  48516. private _loadedMeshInfo;
  48517. protected readonly _mapping: {
  48518. buttons: string[];
  48519. buttonMeshNames: {
  48520. 'trigger': string;
  48521. 'menu': string;
  48522. 'grip': string;
  48523. 'thumbstick': string;
  48524. 'trackpad': string;
  48525. };
  48526. buttonObservableNames: {
  48527. 'trigger': string;
  48528. 'menu': string;
  48529. 'grip': string;
  48530. 'thumbstick': string;
  48531. 'trackpad': string;
  48532. };
  48533. axisMeshNames: string[];
  48534. pointingPoseMeshName: string;
  48535. };
  48536. /**
  48537. * Fired when the trackpad on this controller is clicked
  48538. */
  48539. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48540. /**
  48541. * Fired when the trackpad on this controller is modified
  48542. */
  48543. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48544. /**
  48545. * The current x and y values of this controller's trackpad
  48546. */
  48547. trackpad: StickValues;
  48548. /**
  48549. * Creates a new WindowsMotionController from a gamepad
  48550. * @param vrGamepad the gamepad that the controller should be created from
  48551. */
  48552. constructor(vrGamepad: any);
  48553. /**
  48554. * Fired when the trigger on this controller is modified
  48555. */
  48556. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48557. /**
  48558. * Fired when the menu button on this controller is modified
  48559. */
  48560. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48561. /**
  48562. * Fired when the grip button on this controller is modified
  48563. */
  48564. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48565. /**
  48566. * Fired when the thumbstick button on this controller is modified
  48567. */
  48568. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48569. /**
  48570. * Fired when the touchpad button on this controller is modified
  48571. */
  48572. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48573. /**
  48574. * Fired when the touchpad values on this controller are modified
  48575. */
  48576. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48577. protected _updateTrackpad(): void;
  48578. /**
  48579. * Called once per frame by the engine.
  48580. */
  48581. update(): void;
  48582. /**
  48583. * Called once for each button that changed state since the last frame
  48584. * @param buttonIdx Which button index changed
  48585. * @param state New state of the button
  48586. * @param changes Which properties on the state changed since last frame
  48587. */
  48588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48589. /**
  48590. * Moves the buttons on the controller mesh based on their current state
  48591. * @param buttonName the name of the button to move
  48592. * @param buttonValue the value of the button which determines the buttons new position
  48593. */
  48594. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48595. /**
  48596. * Moves the axis on the controller mesh based on its current state
  48597. * @param axis the index of the axis
  48598. * @param axisValue the value of the axis which determines the meshes new position
  48599. * @hidden
  48600. */
  48601. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48602. /**
  48603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48604. * @param scene scene in which to add meshes
  48605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48606. */
  48607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48608. /**
  48609. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48610. * can be transformed by button presses and axes values, based on this._mapping.
  48611. *
  48612. * @param scene scene in which the meshes exist
  48613. * @param meshes list of meshes that make up the controller model to process
  48614. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48615. */
  48616. private processModel;
  48617. private createMeshInfo;
  48618. /**
  48619. * Gets the ray of the controller in the direction the controller is pointing
  48620. * @param length the length the resulting ray should be
  48621. * @returns a ray in the direction the controller is pointing
  48622. */
  48623. getForwardRay(length?: number): Ray;
  48624. /**
  48625. * Disposes of the controller
  48626. */
  48627. dispose(): void;
  48628. }
  48629. /**
  48630. * This class represents a new windows motion controller in XR.
  48631. */
  48632. export class XRWindowsMotionController extends WindowsMotionController {
  48633. /**
  48634. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48635. */
  48636. protected readonly _mapping: {
  48637. buttons: string[];
  48638. buttonMeshNames: {
  48639. 'trigger': string;
  48640. 'menu': string;
  48641. 'grip': string;
  48642. 'thumbstick': string;
  48643. 'trackpad': string;
  48644. };
  48645. buttonObservableNames: {
  48646. 'trigger': string;
  48647. 'menu': string;
  48648. 'grip': string;
  48649. 'thumbstick': string;
  48650. 'trackpad': string;
  48651. };
  48652. axisMeshNames: string[];
  48653. pointingPoseMeshName: string;
  48654. };
  48655. /**
  48656. * Construct a new XR-Based windows motion controller
  48657. *
  48658. * @param gamepadInfo the gamepad object from the browser
  48659. */
  48660. constructor(gamepadInfo: any);
  48661. /**
  48662. * holds the thumbstick values (X,Y)
  48663. */
  48664. thumbstickValues: StickValues;
  48665. /**
  48666. * Fired when the thumbstick on this controller is clicked
  48667. */
  48668. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48669. /**
  48670. * Fired when the thumbstick on this controller is modified
  48671. */
  48672. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48673. /**
  48674. * Fired when the touchpad button on this controller is modified
  48675. */
  48676. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48677. /**
  48678. * Fired when the touchpad values on this controller are modified
  48679. */
  48680. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48681. /**
  48682. * Fired when the thumbstick button on this controller is modified
  48683. * here to prevent breaking changes
  48684. */
  48685. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48686. /**
  48687. * updating the thumbstick(!) and not the trackpad.
  48688. * This is named this way due to the difference between WebVR and XR and to avoid
  48689. * changing the parent class.
  48690. */
  48691. protected _updateTrackpad(): void;
  48692. /**
  48693. * Disposes the class with joy
  48694. */
  48695. dispose(): void;
  48696. }
  48697. }
  48698. declare module BABYLON {
  48699. /**
  48700. * Class containing static functions to help procedurally build meshes
  48701. */
  48702. export class PolyhedronBuilder {
  48703. /**
  48704. * Creates a polyhedron mesh
  48705. * * 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
  48706. * * The parameter `size` (positive float, default 1) sets the polygon size
  48707. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48708. * * 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`
  48709. * * 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
  48710. * * 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)`)
  48711. * * 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
  48712. * * 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
  48713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48714. * * 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
  48715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48716. * @param name defines the name of the mesh
  48717. * @param options defines the options used to create the mesh
  48718. * @param scene defines the hosting scene
  48719. * @returns the polyhedron mesh
  48720. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48721. */
  48722. static CreatePolyhedron(name: string, options: {
  48723. type?: number;
  48724. size?: number;
  48725. sizeX?: number;
  48726. sizeY?: number;
  48727. sizeZ?: number;
  48728. custom?: any;
  48729. faceUV?: Vector4[];
  48730. faceColors?: Color4[];
  48731. flat?: boolean;
  48732. updatable?: boolean;
  48733. sideOrientation?: number;
  48734. frontUVs?: Vector4;
  48735. backUVs?: Vector4;
  48736. }, scene?: Nullable<Scene>): Mesh;
  48737. }
  48738. }
  48739. declare module BABYLON {
  48740. /**
  48741. * Gizmo that enables scaling a mesh along 3 axis
  48742. */
  48743. export class ScaleGizmo extends Gizmo {
  48744. /**
  48745. * Internal gizmo used for interactions on the x axis
  48746. */
  48747. xGizmo: AxisScaleGizmo;
  48748. /**
  48749. * Internal gizmo used for interactions on the y axis
  48750. */
  48751. yGizmo: AxisScaleGizmo;
  48752. /**
  48753. * Internal gizmo used for interactions on the z axis
  48754. */
  48755. zGizmo: AxisScaleGizmo;
  48756. /**
  48757. * Internal gizmo used to scale all axis equally
  48758. */
  48759. uniformScaleGizmo: AxisScaleGizmo;
  48760. private _meshAttached;
  48761. private _updateGizmoRotationToMatchAttachedMesh;
  48762. private _snapDistance;
  48763. private _scaleRatio;
  48764. private _uniformScalingMesh;
  48765. private _octahedron;
  48766. private _sensitivity;
  48767. /** Fires an event when any of it's sub gizmos are dragged */
  48768. onDragStartObservable: Observable<unknown>;
  48769. /** Fires an event when any of it's sub gizmos are released from dragging */
  48770. onDragEndObservable: Observable<unknown>;
  48771. get attachedMesh(): Nullable<AbstractMesh>;
  48772. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48773. /**
  48774. * Creates a ScaleGizmo
  48775. * @param gizmoLayer The utility layer the gizmo will be added to
  48776. */
  48777. constructor(gizmoLayer?: UtilityLayerRenderer);
  48778. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48779. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48780. /**
  48781. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48782. */
  48783. set snapDistance(value: number);
  48784. get snapDistance(): number;
  48785. /**
  48786. * Ratio for the scale of the gizmo (Default: 1)
  48787. */
  48788. set scaleRatio(value: number);
  48789. get scaleRatio(): number;
  48790. /**
  48791. * Sensitivity factor for dragging (Default: 1)
  48792. */
  48793. set sensitivity(value: number);
  48794. get sensitivity(): number;
  48795. /**
  48796. * Disposes of the gizmo
  48797. */
  48798. dispose(): void;
  48799. }
  48800. }
  48801. declare module BABYLON {
  48802. /**
  48803. * Single axis scale gizmo
  48804. */
  48805. export class AxisScaleGizmo extends Gizmo {
  48806. /**
  48807. * Drag behavior responsible for the gizmos dragging interactions
  48808. */
  48809. dragBehavior: PointerDragBehavior;
  48810. private _pointerObserver;
  48811. /**
  48812. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48813. */
  48814. snapDistance: number;
  48815. /**
  48816. * Event that fires each time the gizmo snaps to a new location.
  48817. * * snapDistance is the the change in distance
  48818. */
  48819. onSnapObservable: Observable<{
  48820. snapDistance: number;
  48821. }>;
  48822. /**
  48823. * If the scaling operation should be done on all axis (default: false)
  48824. */
  48825. uniformScaling: boolean;
  48826. /**
  48827. * Custom sensitivity value for the drag strength
  48828. */
  48829. sensitivity: number;
  48830. private _isEnabled;
  48831. private _parent;
  48832. private _arrow;
  48833. private _coloredMaterial;
  48834. private _hoverMaterial;
  48835. /**
  48836. * Creates an AxisScaleGizmo
  48837. * @param gizmoLayer The utility layer the gizmo will be added to
  48838. * @param dragAxis The axis which the gizmo will be able to scale on
  48839. * @param color The color of the gizmo
  48840. */
  48841. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48842. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48843. /**
  48844. * If the gizmo is enabled
  48845. */
  48846. set isEnabled(value: boolean);
  48847. get isEnabled(): boolean;
  48848. /**
  48849. * Disposes of the gizmo
  48850. */
  48851. dispose(): void;
  48852. /**
  48853. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48854. * @param mesh The mesh to replace the default mesh of the gizmo
  48855. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48856. */
  48857. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48858. }
  48859. }
  48860. declare module BABYLON {
  48861. /**
  48862. * Bounding box gizmo
  48863. */
  48864. export class BoundingBoxGizmo extends Gizmo {
  48865. private _lineBoundingBox;
  48866. private _rotateSpheresParent;
  48867. private _scaleBoxesParent;
  48868. private _boundingDimensions;
  48869. private _renderObserver;
  48870. private _pointerObserver;
  48871. private _scaleDragSpeed;
  48872. private _tmpQuaternion;
  48873. private _tmpVector;
  48874. private _tmpRotationMatrix;
  48875. /**
  48876. * 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)
  48877. */
  48878. ignoreChildren: boolean;
  48879. /**
  48880. * 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)
  48881. */
  48882. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48883. /**
  48884. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48885. */
  48886. rotationSphereSize: number;
  48887. /**
  48888. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48889. */
  48890. scaleBoxSize: number;
  48891. /**
  48892. * 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)
  48893. */
  48894. fixedDragMeshScreenSize: boolean;
  48895. /**
  48896. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48897. */
  48898. fixedDragMeshScreenSizeDistanceFactor: number;
  48899. /**
  48900. * Fired when a rotation sphere or scale box is dragged
  48901. */
  48902. onDragStartObservable: Observable<{}>;
  48903. /**
  48904. * Fired when a scale box is dragged
  48905. */
  48906. onScaleBoxDragObservable: Observable<{}>;
  48907. /**
  48908. * Fired when a scale box drag is ended
  48909. */
  48910. onScaleBoxDragEndObservable: Observable<{}>;
  48911. /**
  48912. * Fired when a rotation sphere is dragged
  48913. */
  48914. onRotationSphereDragObservable: Observable<{}>;
  48915. /**
  48916. * Fired when a rotation sphere drag is ended
  48917. */
  48918. onRotationSphereDragEndObservable: Observable<{}>;
  48919. /**
  48920. * 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)
  48921. */
  48922. scalePivot: Nullable<Vector3>;
  48923. /**
  48924. * Mesh used as a pivot to rotate the attached mesh
  48925. */
  48926. private _anchorMesh;
  48927. private _existingMeshScale;
  48928. private _dragMesh;
  48929. private pointerDragBehavior;
  48930. private coloredMaterial;
  48931. private hoverColoredMaterial;
  48932. /**
  48933. * Sets the color of the bounding box gizmo
  48934. * @param color the color to set
  48935. */
  48936. setColor(color: Color3): void;
  48937. /**
  48938. * Creates an BoundingBoxGizmo
  48939. * @param gizmoLayer The utility layer the gizmo will be added to
  48940. * @param color The color of the gizmo
  48941. */
  48942. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48943. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48944. private _selectNode;
  48945. /**
  48946. * Updates the bounding box information for the Gizmo
  48947. */
  48948. updateBoundingBox(): void;
  48949. private _updateRotationSpheres;
  48950. private _updateScaleBoxes;
  48951. /**
  48952. * Enables rotation on the specified axis and disables rotation on the others
  48953. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48954. */
  48955. setEnabledRotationAxis(axis: string): void;
  48956. /**
  48957. * Enables/disables scaling
  48958. * @param enable if scaling should be enabled
  48959. * @param homogeneousScaling defines if scaling should only be homogeneous
  48960. */
  48961. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48962. private _updateDummy;
  48963. /**
  48964. * Enables a pointer drag behavior on the bounding box of the gizmo
  48965. */
  48966. enableDragBehavior(): void;
  48967. /**
  48968. * Disposes of the gizmo
  48969. */
  48970. dispose(): void;
  48971. /**
  48972. * 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)
  48973. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48974. * @returns the bounding box mesh with the passed in mesh as a child
  48975. */
  48976. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48977. /**
  48978. * CustomMeshes are not supported by this gizmo
  48979. * @param mesh The mesh to replace the default mesh of the gizmo
  48980. */
  48981. setCustomMesh(mesh: Mesh): void;
  48982. }
  48983. }
  48984. declare module BABYLON {
  48985. /**
  48986. * Single plane rotation gizmo
  48987. */
  48988. export class PlaneRotationGizmo extends Gizmo {
  48989. /**
  48990. * Drag behavior responsible for the gizmos dragging interactions
  48991. */
  48992. dragBehavior: PointerDragBehavior;
  48993. private _pointerObserver;
  48994. /**
  48995. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48996. */
  48997. snapDistance: number;
  48998. /**
  48999. * Event that fires each time the gizmo snaps to a new location.
  49000. * * snapDistance is the the change in distance
  49001. */
  49002. onSnapObservable: Observable<{
  49003. snapDistance: number;
  49004. }>;
  49005. private _isEnabled;
  49006. private _parent;
  49007. /**
  49008. * Creates a PlaneRotationGizmo
  49009. * @param gizmoLayer The utility layer the gizmo will be added to
  49010. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49011. * @param color The color of the gizmo
  49012. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49013. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49014. */
  49015. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49016. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49017. /**
  49018. * If the gizmo is enabled
  49019. */
  49020. set isEnabled(value: boolean);
  49021. get isEnabled(): boolean;
  49022. /**
  49023. * Disposes of the gizmo
  49024. */
  49025. dispose(): void;
  49026. }
  49027. }
  49028. declare module BABYLON {
  49029. /**
  49030. * Gizmo that enables rotating a mesh along 3 axis
  49031. */
  49032. export class RotationGizmo extends Gizmo {
  49033. /**
  49034. * Internal gizmo used for interactions on the x axis
  49035. */
  49036. xGizmo: PlaneRotationGizmo;
  49037. /**
  49038. * Internal gizmo used for interactions on the y axis
  49039. */
  49040. yGizmo: PlaneRotationGizmo;
  49041. /**
  49042. * Internal gizmo used for interactions on the z axis
  49043. */
  49044. zGizmo: PlaneRotationGizmo;
  49045. /** Fires an event when any of it's sub gizmos are dragged */
  49046. onDragStartObservable: Observable<unknown>;
  49047. /** Fires an event when any of it's sub gizmos are released from dragging */
  49048. onDragEndObservable: Observable<unknown>;
  49049. private _meshAttached;
  49050. get attachedMesh(): Nullable<AbstractMesh>;
  49051. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49052. /**
  49053. * Creates a RotationGizmo
  49054. * @param gizmoLayer The utility layer the gizmo will be added to
  49055. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49056. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49057. */
  49058. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49059. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49060. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49061. /**
  49062. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49063. */
  49064. set snapDistance(value: number);
  49065. get snapDistance(): number;
  49066. /**
  49067. * Ratio for the scale of the gizmo (Default: 1)
  49068. */
  49069. set scaleRatio(value: number);
  49070. get scaleRatio(): number;
  49071. /**
  49072. * Disposes of the gizmo
  49073. */
  49074. dispose(): void;
  49075. /**
  49076. * CustomMeshes are not supported by this gizmo
  49077. * @param mesh The mesh to replace the default mesh of the gizmo
  49078. */
  49079. setCustomMesh(mesh: Mesh): void;
  49080. }
  49081. }
  49082. declare module BABYLON {
  49083. /**
  49084. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49085. */
  49086. export class GizmoManager implements IDisposable {
  49087. private scene;
  49088. /**
  49089. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49090. */
  49091. gizmos: {
  49092. positionGizmo: Nullable<PositionGizmo>;
  49093. rotationGizmo: Nullable<RotationGizmo>;
  49094. scaleGizmo: Nullable<ScaleGizmo>;
  49095. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49096. };
  49097. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49098. clearGizmoOnEmptyPointerEvent: boolean;
  49099. /** Fires an event when the manager is attached to a mesh */
  49100. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49101. private _gizmosEnabled;
  49102. private _pointerObserver;
  49103. private _attachedMesh;
  49104. private _boundingBoxColor;
  49105. private _defaultUtilityLayer;
  49106. private _defaultKeepDepthUtilityLayer;
  49107. /**
  49108. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49109. */
  49110. boundingBoxDragBehavior: SixDofDragBehavior;
  49111. /**
  49112. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49113. */
  49114. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49115. /**
  49116. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49117. */
  49118. usePointerToAttachGizmos: boolean;
  49119. /**
  49120. * Utility layer that the bounding box gizmo belongs to
  49121. */
  49122. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49123. /**
  49124. * Utility layer that all gizmos besides bounding box belong to
  49125. */
  49126. get utilityLayer(): UtilityLayerRenderer;
  49127. /**
  49128. * Instatiates a gizmo manager
  49129. * @param scene the scene to overlay the gizmos on top of
  49130. */
  49131. constructor(scene: Scene);
  49132. /**
  49133. * Attaches a set of gizmos to the specified mesh
  49134. * @param mesh The mesh the gizmo's should be attached to
  49135. */
  49136. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49137. /**
  49138. * If the position gizmo is enabled
  49139. */
  49140. set positionGizmoEnabled(value: boolean);
  49141. get positionGizmoEnabled(): boolean;
  49142. /**
  49143. * If the rotation gizmo is enabled
  49144. */
  49145. set rotationGizmoEnabled(value: boolean);
  49146. get rotationGizmoEnabled(): boolean;
  49147. /**
  49148. * If the scale gizmo is enabled
  49149. */
  49150. set scaleGizmoEnabled(value: boolean);
  49151. get scaleGizmoEnabled(): boolean;
  49152. /**
  49153. * If the boundingBox gizmo is enabled
  49154. */
  49155. set boundingBoxGizmoEnabled(value: boolean);
  49156. get boundingBoxGizmoEnabled(): boolean;
  49157. /**
  49158. * Disposes of the gizmo manager
  49159. */
  49160. dispose(): void;
  49161. }
  49162. }
  49163. declare module BABYLON {
  49164. /**
  49165. * A directional light is defined by a direction (what a surprise!).
  49166. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49167. * 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.
  49168. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49169. */
  49170. export class DirectionalLight extends ShadowLight {
  49171. private _shadowFrustumSize;
  49172. /**
  49173. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49174. */
  49175. get shadowFrustumSize(): number;
  49176. /**
  49177. * Specifies a fix frustum size for the shadow generation.
  49178. */
  49179. set shadowFrustumSize(value: number);
  49180. private _shadowOrthoScale;
  49181. /**
  49182. * Gets the shadow projection scale against the optimal computed one.
  49183. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49184. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49185. */
  49186. get shadowOrthoScale(): number;
  49187. /**
  49188. * Sets the shadow projection scale against the optimal computed one.
  49189. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49190. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49191. */
  49192. set shadowOrthoScale(value: number);
  49193. /**
  49194. * Automatically compute the projection matrix to best fit (including all the casters)
  49195. * on each frame.
  49196. */
  49197. autoUpdateExtends: boolean;
  49198. /**
  49199. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49200. * on each frame. autoUpdateExtends must be set to true for this to work
  49201. */
  49202. autoCalcShadowZBounds: boolean;
  49203. private _orthoLeft;
  49204. private _orthoRight;
  49205. private _orthoTop;
  49206. private _orthoBottom;
  49207. /**
  49208. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49209. * The directional light is emitted from everywhere in the given direction.
  49210. * It can cast shadows.
  49211. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49212. * @param name The friendly name of the light
  49213. * @param direction The direction of the light
  49214. * @param scene The scene the light belongs to
  49215. */
  49216. constructor(name: string, direction: Vector3, scene: Scene);
  49217. /**
  49218. * Returns the string "DirectionalLight".
  49219. * @return The class name
  49220. */
  49221. getClassName(): string;
  49222. /**
  49223. * Returns the integer 1.
  49224. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49225. */
  49226. getTypeID(): number;
  49227. /**
  49228. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49229. * Returns the DirectionalLight Shadow projection matrix.
  49230. */
  49231. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49232. /**
  49233. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49234. * Returns the DirectionalLight Shadow projection matrix.
  49235. */
  49236. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49237. /**
  49238. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49239. * Returns the DirectionalLight Shadow projection matrix.
  49240. */
  49241. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49242. protected _buildUniformLayout(): void;
  49243. /**
  49244. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49245. * @param effect The effect to update
  49246. * @param lightIndex The index of the light in the effect to update
  49247. * @returns The directional light
  49248. */
  49249. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49250. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49251. /**
  49252. * Gets the minZ used for shadow according to both the scene and the light.
  49253. *
  49254. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49255. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49256. * @param activeCamera The camera we are returning the min for
  49257. * @returns the depth min z
  49258. */
  49259. getDepthMinZ(activeCamera: Camera): number;
  49260. /**
  49261. * Gets the maxZ used for shadow according to both the scene and the light.
  49262. *
  49263. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49264. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49265. * @param activeCamera The camera we are returning the max for
  49266. * @returns the depth max z
  49267. */
  49268. getDepthMaxZ(activeCamera: Camera): number;
  49269. /**
  49270. * Prepares the list of defines specific to the light type.
  49271. * @param defines the list of defines
  49272. * @param lightIndex defines the index of the light for the effect
  49273. */
  49274. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49275. }
  49276. }
  49277. declare module BABYLON {
  49278. /**
  49279. * Class containing static functions to help procedurally build meshes
  49280. */
  49281. export class HemisphereBuilder {
  49282. /**
  49283. * Creates a hemisphere mesh
  49284. * @param name defines the name of the mesh
  49285. * @param options defines the options used to create the mesh
  49286. * @param scene defines the hosting scene
  49287. * @returns the hemisphere mesh
  49288. */
  49289. static CreateHemisphere(name: string, options: {
  49290. segments?: number;
  49291. diameter?: number;
  49292. sideOrientation?: number;
  49293. }, scene: any): Mesh;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49299. * These values define a cone of light starting from the position, emitting toward the direction.
  49300. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49301. * and the exponent defines the speed of the decay of the light with distance (reach).
  49302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49303. */
  49304. export class SpotLight extends ShadowLight {
  49305. private _angle;
  49306. private _innerAngle;
  49307. private _cosHalfAngle;
  49308. private _lightAngleScale;
  49309. private _lightAngleOffset;
  49310. /**
  49311. * Gets the cone angle of the spot light in Radians.
  49312. */
  49313. get angle(): number;
  49314. /**
  49315. * Sets the cone angle of the spot light in Radians.
  49316. */
  49317. set angle(value: number);
  49318. /**
  49319. * Only used in gltf falloff mode, this defines the angle where
  49320. * the directional falloff will start before cutting at angle which could be seen
  49321. * as outer angle.
  49322. */
  49323. get innerAngle(): number;
  49324. /**
  49325. * Only used in gltf falloff mode, this defines the angle where
  49326. * the directional falloff will start before cutting at angle which could be seen
  49327. * as outer angle.
  49328. */
  49329. set innerAngle(value: number);
  49330. private _shadowAngleScale;
  49331. /**
  49332. * Allows scaling the angle of the light for shadow generation only.
  49333. */
  49334. get shadowAngleScale(): number;
  49335. /**
  49336. * Allows scaling the angle of the light for shadow generation only.
  49337. */
  49338. set shadowAngleScale(value: number);
  49339. /**
  49340. * The light decay speed with the distance from the emission spot.
  49341. */
  49342. exponent: number;
  49343. private _projectionTextureMatrix;
  49344. /**
  49345. * Allows reading the projecton texture
  49346. */
  49347. get projectionTextureMatrix(): Matrix;
  49348. protected _projectionTextureLightNear: number;
  49349. /**
  49350. * Gets the near clip of the Spotlight for texture projection.
  49351. */
  49352. get projectionTextureLightNear(): number;
  49353. /**
  49354. * Sets the near clip of the Spotlight for texture projection.
  49355. */
  49356. set projectionTextureLightNear(value: number);
  49357. protected _projectionTextureLightFar: number;
  49358. /**
  49359. * Gets the far clip of the Spotlight for texture projection.
  49360. */
  49361. get projectionTextureLightFar(): number;
  49362. /**
  49363. * Sets the far clip of the Spotlight for texture projection.
  49364. */
  49365. set projectionTextureLightFar(value: number);
  49366. protected _projectionTextureUpDirection: Vector3;
  49367. /**
  49368. * Gets the Up vector of the Spotlight for texture projection.
  49369. */
  49370. get projectionTextureUpDirection(): Vector3;
  49371. /**
  49372. * Sets the Up vector of the Spotlight for texture projection.
  49373. */
  49374. set projectionTextureUpDirection(value: Vector3);
  49375. private _projectionTexture;
  49376. /**
  49377. * Gets the projection texture of the light.
  49378. */
  49379. get projectionTexture(): Nullable<BaseTexture>;
  49380. /**
  49381. * Sets the projection texture of the light.
  49382. */
  49383. set projectionTexture(value: Nullable<BaseTexture>);
  49384. private _projectionTextureViewLightDirty;
  49385. private _projectionTextureProjectionLightDirty;
  49386. private _projectionTextureDirty;
  49387. private _projectionTextureViewTargetVector;
  49388. private _projectionTextureViewLightMatrix;
  49389. private _projectionTextureProjectionLightMatrix;
  49390. private _projectionTextureScalingMatrix;
  49391. /**
  49392. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49393. * It can cast shadows.
  49394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49395. * @param name The light friendly name
  49396. * @param position The position of the spot light in the scene
  49397. * @param direction The direction of the light in the scene
  49398. * @param angle The cone angle of the light in Radians
  49399. * @param exponent The light decay speed with the distance from the emission spot
  49400. * @param scene The scene the lights belongs to
  49401. */
  49402. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49403. /**
  49404. * Returns the string "SpotLight".
  49405. * @returns the class name
  49406. */
  49407. getClassName(): string;
  49408. /**
  49409. * Returns the integer 2.
  49410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49411. */
  49412. getTypeID(): number;
  49413. /**
  49414. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49415. */
  49416. protected _setDirection(value: Vector3): void;
  49417. /**
  49418. * Overrides the position setter to recompute the projection texture view light Matrix.
  49419. */
  49420. protected _setPosition(value: Vector3): void;
  49421. /**
  49422. * 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.
  49423. * Returns the SpotLight.
  49424. */
  49425. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49426. protected _computeProjectionTextureViewLightMatrix(): void;
  49427. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49428. /**
  49429. * Main function for light texture projection matrix computing.
  49430. */
  49431. protected _computeProjectionTextureMatrix(): void;
  49432. protected _buildUniformLayout(): void;
  49433. private _computeAngleValues;
  49434. /**
  49435. * Sets the passed Effect "effect" with the Light textures.
  49436. * @param effect The effect to update
  49437. * @param lightIndex The index of the light in the effect to update
  49438. * @returns The light
  49439. */
  49440. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49441. /**
  49442. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49443. * @param effect The effect to update
  49444. * @param lightIndex The index of the light in the effect to update
  49445. * @returns The spot light
  49446. */
  49447. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49448. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49449. /**
  49450. * Disposes the light and the associated resources.
  49451. */
  49452. dispose(): void;
  49453. /**
  49454. * Prepares the list of defines specific to the light type.
  49455. * @param defines the list of defines
  49456. * @param lightIndex defines the index of the light for the effect
  49457. */
  49458. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49459. }
  49460. }
  49461. declare module BABYLON {
  49462. /**
  49463. * Gizmo that enables viewing a light
  49464. */
  49465. export class LightGizmo extends Gizmo {
  49466. private _lightMesh;
  49467. private _material;
  49468. private _cachedPosition;
  49469. private _cachedForward;
  49470. private _attachedMeshParent;
  49471. /**
  49472. * Creates a LightGizmo
  49473. * @param gizmoLayer The utility layer the gizmo will be added to
  49474. */
  49475. constructor(gizmoLayer?: UtilityLayerRenderer);
  49476. private _light;
  49477. /**
  49478. * The light that the gizmo is attached to
  49479. */
  49480. set light(light: Nullable<Light>);
  49481. get light(): Nullable<Light>;
  49482. /**
  49483. * Gets the material used to render the light gizmo
  49484. */
  49485. get material(): StandardMaterial;
  49486. /**
  49487. * @hidden
  49488. * Updates the gizmo to match the attached mesh's position/rotation
  49489. */
  49490. protected _update(): void;
  49491. private static _Scale;
  49492. /**
  49493. * Creates the lines for a light mesh
  49494. */
  49495. private static _CreateLightLines;
  49496. /**
  49497. * Disposes of the light gizmo
  49498. */
  49499. dispose(): void;
  49500. private static _CreateHemisphericLightMesh;
  49501. private static _CreatePointLightMesh;
  49502. private static _CreateSpotLightMesh;
  49503. private static _CreateDirectionalLightMesh;
  49504. }
  49505. }
  49506. declare module BABYLON {
  49507. /** @hidden */
  49508. export var backgroundFragmentDeclaration: {
  49509. name: string;
  49510. shader: string;
  49511. };
  49512. }
  49513. declare module BABYLON {
  49514. /** @hidden */
  49515. export var backgroundUboDeclaration: {
  49516. name: string;
  49517. shader: string;
  49518. };
  49519. }
  49520. declare module BABYLON {
  49521. /** @hidden */
  49522. export var backgroundPixelShader: {
  49523. name: string;
  49524. shader: string;
  49525. };
  49526. }
  49527. declare module BABYLON {
  49528. /** @hidden */
  49529. export var backgroundVertexDeclaration: {
  49530. name: string;
  49531. shader: string;
  49532. };
  49533. }
  49534. declare module BABYLON {
  49535. /** @hidden */
  49536. export var backgroundVertexShader: {
  49537. name: string;
  49538. shader: string;
  49539. };
  49540. }
  49541. declare module BABYLON {
  49542. /**
  49543. * Background material used to create an efficient environement around your scene.
  49544. */
  49545. export class BackgroundMaterial extends PushMaterial {
  49546. /**
  49547. * Standard reflectance value at parallel view angle.
  49548. */
  49549. static StandardReflectance0: number;
  49550. /**
  49551. * Standard reflectance value at grazing angle.
  49552. */
  49553. static StandardReflectance90: number;
  49554. protected _primaryColor: Color3;
  49555. /**
  49556. * Key light Color (multiply against the environement texture)
  49557. */
  49558. primaryColor: Color3;
  49559. protected __perceptualColor: Nullable<Color3>;
  49560. /**
  49561. * Experimental Internal Use Only.
  49562. *
  49563. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49564. * This acts as a helper to set the primary color to a more "human friendly" value.
  49565. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49566. * output color as close as possible from the chosen value.
  49567. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49568. * part of lighting setup.)
  49569. */
  49570. get _perceptualColor(): Nullable<Color3>;
  49571. set _perceptualColor(value: Nullable<Color3>);
  49572. protected _primaryColorShadowLevel: float;
  49573. /**
  49574. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49575. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49576. */
  49577. get primaryColorShadowLevel(): float;
  49578. set primaryColorShadowLevel(value: float);
  49579. protected _primaryColorHighlightLevel: float;
  49580. /**
  49581. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49582. * The primary color is used at the level chosen to define what the white area would look.
  49583. */
  49584. get primaryColorHighlightLevel(): float;
  49585. set primaryColorHighlightLevel(value: float);
  49586. protected _reflectionTexture: Nullable<BaseTexture>;
  49587. /**
  49588. * Reflection Texture used in the material.
  49589. * Should be author in a specific way for the best result (refer to the documentation).
  49590. */
  49591. reflectionTexture: Nullable<BaseTexture>;
  49592. protected _reflectionBlur: float;
  49593. /**
  49594. * Reflection Texture level of blur.
  49595. *
  49596. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49597. * texture twice.
  49598. */
  49599. reflectionBlur: float;
  49600. protected _diffuseTexture: Nullable<BaseTexture>;
  49601. /**
  49602. * Diffuse Texture used in the material.
  49603. * Should be author in a specific way for the best result (refer to the documentation).
  49604. */
  49605. diffuseTexture: Nullable<BaseTexture>;
  49606. protected _shadowLights: Nullable<IShadowLight[]>;
  49607. /**
  49608. * Specify the list of lights casting shadow on the material.
  49609. * All scene shadow lights will be included if null.
  49610. */
  49611. shadowLights: Nullable<IShadowLight[]>;
  49612. protected _shadowLevel: float;
  49613. /**
  49614. * Helps adjusting the shadow to a softer level if required.
  49615. * 0 means black shadows and 1 means no shadows.
  49616. */
  49617. shadowLevel: float;
  49618. protected _sceneCenter: Vector3;
  49619. /**
  49620. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49621. * It is usually zero but might be interesting to modify according to your setup.
  49622. */
  49623. sceneCenter: Vector3;
  49624. protected _opacityFresnel: boolean;
  49625. /**
  49626. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49627. * This helps ensuring a nice transition when the camera goes under the ground.
  49628. */
  49629. opacityFresnel: boolean;
  49630. protected _reflectionFresnel: boolean;
  49631. /**
  49632. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49633. * This helps adding a mirror texture on the ground.
  49634. */
  49635. reflectionFresnel: boolean;
  49636. protected _reflectionFalloffDistance: number;
  49637. /**
  49638. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49639. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49640. */
  49641. reflectionFalloffDistance: number;
  49642. protected _reflectionAmount: number;
  49643. /**
  49644. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49645. */
  49646. reflectionAmount: number;
  49647. protected _reflectionReflectance0: number;
  49648. /**
  49649. * This specifies the weight of the reflection at grazing angle.
  49650. */
  49651. reflectionReflectance0: number;
  49652. protected _reflectionReflectance90: number;
  49653. /**
  49654. * This specifies the weight of the reflection at a perpendicular point of view.
  49655. */
  49656. reflectionReflectance90: number;
  49657. /**
  49658. * Sets the reflection reflectance fresnel values according to the default standard
  49659. * empirically know to work well :-)
  49660. */
  49661. set reflectionStandardFresnelWeight(value: number);
  49662. protected _useRGBColor: boolean;
  49663. /**
  49664. * Helps to directly use the maps channels instead of their level.
  49665. */
  49666. useRGBColor: boolean;
  49667. protected _enableNoise: boolean;
  49668. /**
  49669. * This helps reducing the banding effect that could occur on the background.
  49670. */
  49671. enableNoise: boolean;
  49672. /**
  49673. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49674. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49675. * Recommended to be keep at 1.0 except for special cases.
  49676. */
  49677. get fovMultiplier(): number;
  49678. set fovMultiplier(value: number);
  49679. private _fovMultiplier;
  49680. /**
  49681. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49682. */
  49683. useEquirectangularFOV: boolean;
  49684. private _maxSimultaneousLights;
  49685. /**
  49686. * Number of Simultaneous lights allowed on the material.
  49687. */
  49688. maxSimultaneousLights: int;
  49689. /**
  49690. * Default configuration related to image processing available in the Background Material.
  49691. */
  49692. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49693. /**
  49694. * Keep track of the image processing observer to allow dispose and replace.
  49695. */
  49696. private _imageProcessingObserver;
  49697. /**
  49698. * Attaches a new image processing configuration to the PBR Material.
  49699. * @param configuration (if null the scene configuration will be use)
  49700. */
  49701. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49702. /**
  49703. * Gets the image processing configuration used either in this material.
  49704. */
  49705. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49706. /**
  49707. * Sets the Default image processing configuration used either in the this material.
  49708. *
  49709. * If sets to null, the scene one is in use.
  49710. */
  49711. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49712. /**
  49713. * Gets wether the color curves effect is enabled.
  49714. */
  49715. get cameraColorCurvesEnabled(): boolean;
  49716. /**
  49717. * Sets wether the color curves effect is enabled.
  49718. */
  49719. set cameraColorCurvesEnabled(value: boolean);
  49720. /**
  49721. * Gets wether the color grading effect is enabled.
  49722. */
  49723. get cameraColorGradingEnabled(): boolean;
  49724. /**
  49725. * Gets wether the color grading effect is enabled.
  49726. */
  49727. set cameraColorGradingEnabled(value: boolean);
  49728. /**
  49729. * Gets wether tonemapping is enabled or not.
  49730. */
  49731. get cameraToneMappingEnabled(): boolean;
  49732. /**
  49733. * Sets wether tonemapping is enabled or not
  49734. */
  49735. set cameraToneMappingEnabled(value: boolean);
  49736. /**
  49737. * The camera exposure used on this material.
  49738. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49739. * This corresponds to a photographic exposure.
  49740. */
  49741. get cameraExposure(): float;
  49742. /**
  49743. * The camera exposure used on this material.
  49744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49745. * This corresponds to a photographic exposure.
  49746. */
  49747. set cameraExposure(value: float);
  49748. /**
  49749. * Gets The camera contrast used on this material.
  49750. */
  49751. get cameraContrast(): float;
  49752. /**
  49753. * Sets The camera contrast used on this material.
  49754. */
  49755. set cameraContrast(value: float);
  49756. /**
  49757. * Gets the Color Grading 2D Lookup Texture.
  49758. */
  49759. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49760. /**
  49761. * Sets the Color Grading 2D Lookup Texture.
  49762. */
  49763. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49764. /**
  49765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49767. * 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;
  49768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49769. */
  49770. get cameraColorCurves(): Nullable<ColorCurves>;
  49771. /**
  49772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49774. * 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;
  49775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49776. */
  49777. set cameraColorCurves(value: Nullable<ColorCurves>);
  49778. /**
  49779. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49780. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49781. */
  49782. switchToBGR: boolean;
  49783. private _renderTargets;
  49784. private _reflectionControls;
  49785. private _white;
  49786. private _primaryShadowColor;
  49787. private _primaryHighlightColor;
  49788. /**
  49789. * Instantiates a Background Material in the given scene
  49790. * @param name The friendly name of the material
  49791. * @param scene The scene to add the material to
  49792. */
  49793. constructor(name: string, scene: Scene);
  49794. /**
  49795. * Gets a boolean indicating that current material needs to register RTT
  49796. */
  49797. get hasRenderTargetTextures(): boolean;
  49798. /**
  49799. * The entire material has been created in order to prevent overdraw.
  49800. * @returns false
  49801. */
  49802. needAlphaTesting(): boolean;
  49803. /**
  49804. * The entire material has been created in order to prevent overdraw.
  49805. * @returns true if blending is enable
  49806. */
  49807. needAlphaBlending(): boolean;
  49808. /**
  49809. * Checks wether the material is ready to be rendered for a given mesh.
  49810. * @param mesh The mesh to render
  49811. * @param subMesh The submesh to check against
  49812. * @param useInstances Specify wether or not the material is used with instances
  49813. * @returns true if all the dependencies are ready (Textures, Effects...)
  49814. */
  49815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49816. /**
  49817. * Compute the primary color according to the chosen perceptual color.
  49818. */
  49819. private _computePrimaryColorFromPerceptualColor;
  49820. /**
  49821. * Compute the highlights and shadow colors according to their chosen levels.
  49822. */
  49823. private _computePrimaryColors;
  49824. /**
  49825. * Build the uniform buffer used in the material.
  49826. */
  49827. buildUniformLayout(): void;
  49828. /**
  49829. * Unbind the material.
  49830. */
  49831. unbind(): void;
  49832. /**
  49833. * Bind only the world matrix to the material.
  49834. * @param world The world matrix to bind.
  49835. */
  49836. bindOnlyWorldMatrix(world: Matrix): void;
  49837. /**
  49838. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49839. * @param world The world matrix to bind.
  49840. * @param subMesh The submesh to bind for.
  49841. */
  49842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49843. /**
  49844. * Checks to see if a texture is used in the material.
  49845. * @param texture - Base texture to use.
  49846. * @returns - Boolean specifying if a texture is used in the material.
  49847. */
  49848. hasTexture(texture: BaseTexture): boolean;
  49849. /**
  49850. * Dispose the material.
  49851. * @param forceDisposeEffect Force disposal of the associated effect.
  49852. * @param forceDisposeTextures Force disposal of the associated textures.
  49853. */
  49854. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49855. /**
  49856. * Clones the material.
  49857. * @param name The cloned name.
  49858. * @returns The cloned material.
  49859. */
  49860. clone(name: string): BackgroundMaterial;
  49861. /**
  49862. * Serializes the current material to its JSON representation.
  49863. * @returns The JSON representation.
  49864. */
  49865. serialize(): any;
  49866. /**
  49867. * Gets the class name of the material
  49868. * @returns "BackgroundMaterial"
  49869. */
  49870. getClassName(): string;
  49871. /**
  49872. * Parse a JSON input to create back a background material.
  49873. * @param source The JSON data to parse
  49874. * @param scene The scene to create the parsed material in
  49875. * @param rootUrl The root url of the assets the material depends upon
  49876. * @returns the instantiated BackgroundMaterial.
  49877. */
  49878. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49879. }
  49880. }
  49881. declare module BABYLON {
  49882. /**
  49883. * Represents the different options available during the creation of
  49884. * a Environment helper.
  49885. *
  49886. * This can control the default ground, skybox and image processing setup of your scene.
  49887. */
  49888. export interface IEnvironmentHelperOptions {
  49889. /**
  49890. * Specifies whether or not to create a ground.
  49891. * True by default.
  49892. */
  49893. createGround: boolean;
  49894. /**
  49895. * Specifies the ground size.
  49896. * 15 by default.
  49897. */
  49898. groundSize: number;
  49899. /**
  49900. * The texture used on the ground for the main color.
  49901. * Comes from the BabylonJS CDN by default.
  49902. *
  49903. * Remarks: Can be either a texture or a url.
  49904. */
  49905. groundTexture: string | BaseTexture;
  49906. /**
  49907. * The color mixed in the ground texture by default.
  49908. * BabylonJS clearColor by default.
  49909. */
  49910. groundColor: Color3;
  49911. /**
  49912. * Specifies the ground opacity.
  49913. * 1 by default.
  49914. */
  49915. groundOpacity: number;
  49916. /**
  49917. * Enables the ground to receive shadows.
  49918. * True by default.
  49919. */
  49920. enableGroundShadow: boolean;
  49921. /**
  49922. * Helps preventing the shadow to be fully black on the ground.
  49923. * 0.5 by default.
  49924. */
  49925. groundShadowLevel: number;
  49926. /**
  49927. * Creates a mirror texture attach to the ground.
  49928. * false by default.
  49929. */
  49930. enableGroundMirror: boolean;
  49931. /**
  49932. * Specifies the ground mirror size ratio.
  49933. * 0.3 by default as the default kernel is 64.
  49934. */
  49935. groundMirrorSizeRatio: number;
  49936. /**
  49937. * Specifies the ground mirror blur kernel size.
  49938. * 64 by default.
  49939. */
  49940. groundMirrorBlurKernel: number;
  49941. /**
  49942. * Specifies the ground mirror visibility amount.
  49943. * 1 by default
  49944. */
  49945. groundMirrorAmount: number;
  49946. /**
  49947. * Specifies the ground mirror reflectance weight.
  49948. * This uses the standard weight of the background material to setup the fresnel effect
  49949. * of the mirror.
  49950. * 1 by default.
  49951. */
  49952. groundMirrorFresnelWeight: number;
  49953. /**
  49954. * Specifies the ground mirror Falloff distance.
  49955. * This can helps reducing the size of the reflection.
  49956. * 0 by Default.
  49957. */
  49958. groundMirrorFallOffDistance: number;
  49959. /**
  49960. * Specifies the ground mirror texture type.
  49961. * Unsigned Int by Default.
  49962. */
  49963. groundMirrorTextureType: number;
  49964. /**
  49965. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49966. * the shown objects.
  49967. */
  49968. groundYBias: number;
  49969. /**
  49970. * Specifies whether or not to create a skybox.
  49971. * True by default.
  49972. */
  49973. createSkybox: boolean;
  49974. /**
  49975. * Specifies the skybox size.
  49976. * 20 by default.
  49977. */
  49978. skyboxSize: number;
  49979. /**
  49980. * The texture used on the skybox for the main color.
  49981. * Comes from the BabylonJS CDN by default.
  49982. *
  49983. * Remarks: Can be either a texture or a url.
  49984. */
  49985. skyboxTexture: string | BaseTexture;
  49986. /**
  49987. * The color mixed in the skybox texture by default.
  49988. * BabylonJS clearColor by default.
  49989. */
  49990. skyboxColor: Color3;
  49991. /**
  49992. * The background rotation around the Y axis of the scene.
  49993. * This helps aligning the key lights of your scene with the background.
  49994. * 0 by default.
  49995. */
  49996. backgroundYRotation: number;
  49997. /**
  49998. * Compute automatically the size of the elements to best fit with the scene.
  49999. */
  50000. sizeAuto: boolean;
  50001. /**
  50002. * Default position of the rootMesh if autoSize is not true.
  50003. */
  50004. rootPosition: Vector3;
  50005. /**
  50006. * Sets up the image processing in the scene.
  50007. * true by default.
  50008. */
  50009. setupImageProcessing: boolean;
  50010. /**
  50011. * The texture used as your environment texture in the scene.
  50012. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50013. *
  50014. * Remarks: Can be either a texture or a url.
  50015. */
  50016. environmentTexture: string | BaseTexture;
  50017. /**
  50018. * The value of the exposure to apply to the scene.
  50019. * 0.6 by default if setupImageProcessing is true.
  50020. */
  50021. cameraExposure: number;
  50022. /**
  50023. * The value of the contrast to apply to the scene.
  50024. * 1.6 by default if setupImageProcessing is true.
  50025. */
  50026. cameraContrast: number;
  50027. /**
  50028. * Specifies whether or not tonemapping should be enabled in the scene.
  50029. * true by default if setupImageProcessing is true.
  50030. */
  50031. toneMappingEnabled: boolean;
  50032. }
  50033. /**
  50034. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50035. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50036. * It also helps with the default setup of your imageProcessing configuration.
  50037. */
  50038. export class EnvironmentHelper {
  50039. /**
  50040. * Default ground texture URL.
  50041. */
  50042. private static _groundTextureCDNUrl;
  50043. /**
  50044. * Default skybox texture URL.
  50045. */
  50046. private static _skyboxTextureCDNUrl;
  50047. /**
  50048. * Default environment texture URL.
  50049. */
  50050. private static _environmentTextureCDNUrl;
  50051. /**
  50052. * Creates the default options for the helper.
  50053. */
  50054. private static _getDefaultOptions;
  50055. private _rootMesh;
  50056. /**
  50057. * Gets the root mesh created by the helper.
  50058. */
  50059. get rootMesh(): Mesh;
  50060. private _skybox;
  50061. /**
  50062. * Gets the skybox created by the helper.
  50063. */
  50064. get skybox(): Nullable<Mesh>;
  50065. private _skyboxTexture;
  50066. /**
  50067. * Gets the skybox texture created by the helper.
  50068. */
  50069. get skyboxTexture(): Nullable<BaseTexture>;
  50070. private _skyboxMaterial;
  50071. /**
  50072. * Gets the skybox material created by the helper.
  50073. */
  50074. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50075. private _ground;
  50076. /**
  50077. * Gets the ground mesh created by the helper.
  50078. */
  50079. get ground(): Nullable<Mesh>;
  50080. private _groundTexture;
  50081. /**
  50082. * Gets the ground texture created by the helper.
  50083. */
  50084. get groundTexture(): Nullable<BaseTexture>;
  50085. private _groundMirror;
  50086. /**
  50087. * Gets the ground mirror created by the helper.
  50088. */
  50089. get groundMirror(): Nullable<MirrorTexture>;
  50090. /**
  50091. * Gets the ground mirror render list to helps pushing the meshes
  50092. * you wish in the ground reflection.
  50093. */
  50094. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50095. private _groundMaterial;
  50096. /**
  50097. * Gets the ground material created by the helper.
  50098. */
  50099. get groundMaterial(): Nullable<BackgroundMaterial>;
  50100. /**
  50101. * Stores the creation options.
  50102. */
  50103. private readonly _scene;
  50104. private _options;
  50105. /**
  50106. * This observable will be notified with any error during the creation of the environment,
  50107. * mainly texture creation errors.
  50108. */
  50109. onErrorObservable: Observable<{
  50110. message?: string;
  50111. exception?: any;
  50112. }>;
  50113. /**
  50114. * constructor
  50115. * @param options Defines the options we want to customize the helper
  50116. * @param scene The scene to add the material to
  50117. */
  50118. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50119. /**
  50120. * Updates the background according to the new options
  50121. * @param options
  50122. */
  50123. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50124. /**
  50125. * Sets the primary color of all the available elements.
  50126. * @param color the main color to affect to the ground and the background
  50127. */
  50128. setMainColor(color: Color3): void;
  50129. /**
  50130. * Setup the image processing according to the specified options.
  50131. */
  50132. private _setupImageProcessing;
  50133. /**
  50134. * Setup the environment texture according to the specified options.
  50135. */
  50136. private _setupEnvironmentTexture;
  50137. /**
  50138. * Setup the background according to the specified options.
  50139. */
  50140. private _setupBackground;
  50141. /**
  50142. * Get the scene sizes according to the setup.
  50143. */
  50144. private _getSceneSize;
  50145. /**
  50146. * Setup the ground according to the specified options.
  50147. */
  50148. private _setupGround;
  50149. /**
  50150. * Setup the ground material according to the specified options.
  50151. */
  50152. private _setupGroundMaterial;
  50153. /**
  50154. * Setup the ground diffuse texture according to the specified options.
  50155. */
  50156. private _setupGroundDiffuseTexture;
  50157. /**
  50158. * Setup the ground mirror texture according to the specified options.
  50159. */
  50160. private _setupGroundMirrorTexture;
  50161. /**
  50162. * Setup the ground to receive the mirror texture.
  50163. */
  50164. private _setupMirrorInGroundMaterial;
  50165. /**
  50166. * Setup the skybox according to the specified options.
  50167. */
  50168. private _setupSkybox;
  50169. /**
  50170. * Setup the skybox material according to the specified options.
  50171. */
  50172. private _setupSkyboxMaterial;
  50173. /**
  50174. * Setup the skybox reflection texture according to the specified options.
  50175. */
  50176. private _setupSkyboxReflectionTexture;
  50177. private _errorHandler;
  50178. /**
  50179. * Dispose all the elements created by the Helper.
  50180. */
  50181. dispose(): void;
  50182. }
  50183. }
  50184. declare module BABYLON {
  50185. /**
  50186. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50187. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50188. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50189. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50190. */
  50191. export class PhotoDome extends TransformNode {
  50192. /**
  50193. * Define the image as a Monoscopic panoramic 360 image.
  50194. */
  50195. static readonly MODE_MONOSCOPIC: number;
  50196. /**
  50197. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50198. */
  50199. static readonly MODE_TOPBOTTOM: number;
  50200. /**
  50201. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50202. */
  50203. static readonly MODE_SIDEBYSIDE: number;
  50204. private _useDirectMapping;
  50205. /**
  50206. * The texture being displayed on the sphere
  50207. */
  50208. protected _photoTexture: Texture;
  50209. /**
  50210. * Gets or sets the texture being displayed on the sphere
  50211. */
  50212. get photoTexture(): Texture;
  50213. set photoTexture(value: Texture);
  50214. /**
  50215. * Observable raised when an error occured while loading the 360 image
  50216. */
  50217. onLoadErrorObservable: Observable<string>;
  50218. /**
  50219. * The skybox material
  50220. */
  50221. protected _material: BackgroundMaterial;
  50222. /**
  50223. * The surface used for the skybox
  50224. */
  50225. protected _mesh: Mesh;
  50226. /**
  50227. * Gets the mesh used for the skybox.
  50228. */
  50229. get mesh(): Mesh;
  50230. /**
  50231. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50232. * Also see the options.resolution property.
  50233. */
  50234. get fovMultiplier(): number;
  50235. set fovMultiplier(value: number);
  50236. private _imageMode;
  50237. /**
  50238. * Gets or set the current video mode for the video. It can be:
  50239. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50240. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50241. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50242. */
  50243. get imageMode(): number;
  50244. set imageMode(value: number);
  50245. /**
  50246. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50247. * @param name Element's name, child elements will append suffixes for their own names.
  50248. * @param urlsOfPhoto defines the url of the photo to display
  50249. * @param options defines an object containing optional or exposed sub element properties
  50250. * @param onError defines a callback called when an error occured while loading the texture
  50251. */
  50252. constructor(name: string, urlOfPhoto: string, options: {
  50253. resolution?: number;
  50254. size?: number;
  50255. useDirectMapping?: boolean;
  50256. faceForward?: boolean;
  50257. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50258. private _onBeforeCameraRenderObserver;
  50259. private _changeImageMode;
  50260. /**
  50261. * Releases resources associated with this node.
  50262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50264. */
  50265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50266. }
  50267. }
  50268. declare module BABYLON {
  50269. /**
  50270. * Class used to host RGBD texture specific utilities
  50271. */
  50272. export class RGBDTextureTools {
  50273. /**
  50274. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50275. * @param texture the texture to expand.
  50276. */
  50277. static ExpandRGBDTexture(texture: Texture): void;
  50278. }
  50279. }
  50280. declare module BABYLON {
  50281. /**
  50282. * Class used to host texture specific utilities
  50283. */
  50284. export class BRDFTextureTools {
  50285. /**
  50286. * Prevents texture cache collision
  50287. */
  50288. private static _instanceNumber;
  50289. /**
  50290. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50291. * @param scene defines the hosting scene
  50292. * @returns the environment BRDF texture
  50293. */
  50294. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50295. private static _environmentBRDFBase64Texture;
  50296. }
  50297. }
  50298. declare module BABYLON {
  50299. /**
  50300. * @hidden
  50301. */
  50302. export interface IMaterialClearCoatDefines {
  50303. CLEARCOAT: boolean;
  50304. CLEARCOAT_DEFAULTIOR: boolean;
  50305. CLEARCOAT_TEXTURE: boolean;
  50306. CLEARCOAT_TEXTUREDIRECTUV: number;
  50307. CLEARCOAT_BUMP: boolean;
  50308. CLEARCOAT_BUMPDIRECTUV: number;
  50309. CLEARCOAT_TINT: boolean;
  50310. CLEARCOAT_TINT_TEXTURE: boolean;
  50311. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50312. /** @hidden */
  50313. _areTexturesDirty: boolean;
  50314. }
  50315. /**
  50316. * Define the code related to the clear coat parameters of the pbr material.
  50317. */
  50318. export class PBRClearCoatConfiguration {
  50319. /**
  50320. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50321. * The default fits with a polyurethane material.
  50322. */
  50323. private static readonly _DefaultIndexOfRefraction;
  50324. private _isEnabled;
  50325. /**
  50326. * Defines if the clear coat is enabled in the material.
  50327. */
  50328. isEnabled: boolean;
  50329. /**
  50330. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50331. */
  50332. intensity: number;
  50333. /**
  50334. * Defines the clear coat layer roughness.
  50335. */
  50336. roughness: number;
  50337. private _indexOfRefraction;
  50338. /**
  50339. * Defines the index of refraction of the clear coat.
  50340. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50341. * The default fits with a polyurethane material.
  50342. * Changing the default value is more performance intensive.
  50343. */
  50344. indexOfRefraction: number;
  50345. private _texture;
  50346. /**
  50347. * Stores the clear coat values in a texture.
  50348. */
  50349. texture: Nullable<BaseTexture>;
  50350. private _bumpTexture;
  50351. /**
  50352. * Define the clear coat specific bump texture.
  50353. */
  50354. bumpTexture: Nullable<BaseTexture>;
  50355. private _isTintEnabled;
  50356. /**
  50357. * Defines if the clear coat tint is enabled in the material.
  50358. */
  50359. isTintEnabled: boolean;
  50360. /**
  50361. * Defines the clear coat tint of the material.
  50362. * This is only use if tint is enabled
  50363. */
  50364. tintColor: Color3;
  50365. /**
  50366. * Defines the distance at which the tint color should be found in the
  50367. * clear coat media.
  50368. * This is only use if tint is enabled
  50369. */
  50370. tintColorAtDistance: number;
  50371. /**
  50372. * Defines the clear coat layer thickness.
  50373. * This is only use if tint is enabled
  50374. */
  50375. tintThickness: number;
  50376. private _tintTexture;
  50377. /**
  50378. * Stores the clear tint values in a texture.
  50379. * rgb is tint
  50380. * a is a thickness factor
  50381. */
  50382. tintTexture: Nullable<BaseTexture>;
  50383. /** @hidden */
  50384. private _internalMarkAllSubMeshesAsTexturesDirty;
  50385. /** @hidden */
  50386. _markAllSubMeshesAsTexturesDirty(): void;
  50387. /**
  50388. * Instantiate a new istance of clear coat configuration.
  50389. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50390. */
  50391. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50392. /**
  50393. * Gets wehter the submesh is ready to be used or not.
  50394. * @param defines the list of "defines" to update.
  50395. * @param scene defines the scene the material belongs to.
  50396. * @param engine defines the engine the material belongs to.
  50397. * @param disableBumpMap defines wether the material disables bump or not.
  50398. * @returns - boolean indicating that the submesh is ready or not.
  50399. */
  50400. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50401. /**
  50402. * Checks to see if a texture is used in the material.
  50403. * @param defines the list of "defines" to update.
  50404. * @param scene defines the scene to the material belongs to.
  50405. */
  50406. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50407. /**
  50408. * Binds the material data.
  50409. * @param uniformBuffer defines the Uniform buffer to fill in.
  50410. * @param scene defines the scene the material belongs to.
  50411. * @param engine defines the engine the material belongs to.
  50412. * @param disableBumpMap defines wether the material disables bump or not.
  50413. * @param isFrozen defines wether the material is frozen or not.
  50414. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50415. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50416. */
  50417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50418. /**
  50419. * Checks to see if a texture is used in the material.
  50420. * @param texture - Base texture to use.
  50421. * @returns - Boolean specifying if a texture is used in the material.
  50422. */
  50423. hasTexture(texture: BaseTexture): boolean;
  50424. /**
  50425. * Returns an array of the actively used textures.
  50426. * @param activeTextures Array of BaseTextures
  50427. */
  50428. getActiveTextures(activeTextures: BaseTexture[]): void;
  50429. /**
  50430. * Returns the animatable textures.
  50431. * @param animatables Array of animatable textures.
  50432. */
  50433. getAnimatables(animatables: IAnimatable[]): void;
  50434. /**
  50435. * Disposes the resources of the material.
  50436. * @param forceDisposeTextures - Forces the disposal of all textures.
  50437. */
  50438. dispose(forceDisposeTextures?: boolean): void;
  50439. /**
  50440. * Get the current class name of the texture useful for serialization or dynamic coding.
  50441. * @returns "PBRClearCoatConfiguration"
  50442. */
  50443. getClassName(): string;
  50444. /**
  50445. * Add fallbacks to the effect fallbacks list.
  50446. * @param defines defines the Base texture to use.
  50447. * @param fallbacks defines the current fallback list.
  50448. * @param currentRank defines the current fallback rank.
  50449. * @returns the new fallback rank.
  50450. */
  50451. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50452. /**
  50453. * Add the required uniforms to the current list.
  50454. * @param uniforms defines the current uniform list.
  50455. */
  50456. static AddUniforms(uniforms: string[]): void;
  50457. /**
  50458. * Add the required samplers to the current list.
  50459. * @param samplers defines the current sampler list.
  50460. */
  50461. static AddSamplers(samplers: string[]): void;
  50462. /**
  50463. * Add the required uniforms to the current buffer.
  50464. * @param uniformBuffer defines the current uniform buffer.
  50465. */
  50466. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50467. /**
  50468. * Makes a duplicate of the current configuration into another one.
  50469. * @param clearCoatConfiguration define the config where to copy the info
  50470. */
  50471. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50472. /**
  50473. * Serializes this clear coat configuration.
  50474. * @returns - An object with the serialized config.
  50475. */
  50476. serialize(): any;
  50477. /**
  50478. * Parses a anisotropy Configuration from a serialized object.
  50479. * @param source - Serialized object.
  50480. * @param scene Defines the scene we are parsing for
  50481. * @param rootUrl Defines the rootUrl to load from
  50482. */
  50483. parse(source: any, scene: Scene, rootUrl: string): void;
  50484. }
  50485. }
  50486. declare module BABYLON {
  50487. /**
  50488. * @hidden
  50489. */
  50490. export interface IMaterialAnisotropicDefines {
  50491. ANISOTROPIC: boolean;
  50492. ANISOTROPIC_TEXTURE: boolean;
  50493. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50494. MAINUV1: boolean;
  50495. _areTexturesDirty: boolean;
  50496. _needUVs: boolean;
  50497. }
  50498. /**
  50499. * Define the code related to the anisotropic parameters of the pbr material.
  50500. */
  50501. export class PBRAnisotropicConfiguration {
  50502. private _isEnabled;
  50503. /**
  50504. * Defines if the anisotropy is enabled in the material.
  50505. */
  50506. isEnabled: boolean;
  50507. /**
  50508. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50509. */
  50510. intensity: number;
  50511. /**
  50512. * Defines if the effect is along the tangents, bitangents or in between.
  50513. * By default, the effect is "strectching" the highlights along the tangents.
  50514. */
  50515. direction: Vector2;
  50516. private _texture;
  50517. /**
  50518. * Stores the anisotropy values in a texture.
  50519. * rg is direction (like normal from -1 to 1)
  50520. * b is a intensity
  50521. */
  50522. texture: Nullable<BaseTexture>;
  50523. /** @hidden */
  50524. private _internalMarkAllSubMeshesAsTexturesDirty;
  50525. /** @hidden */
  50526. _markAllSubMeshesAsTexturesDirty(): void;
  50527. /**
  50528. * Instantiate a new istance of anisotropy configuration.
  50529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50530. */
  50531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50532. /**
  50533. * Specifies that the submesh is ready to be used.
  50534. * @param defines the list of "defines" to update.
  50535. * @param scene defines the scene the material belongs to.
  50536. * @returns - boolean indicating that the submesh is ready or not.
  50537. */
  50538. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50539. /**
  50540. * Checks to see if a texture is used in the material.
  50541. * @param defines the list of "defines" to update.
  50542. * @param mesh the mesh we are preparing the defines for.
  50543. * @param scene defines the scene the material belongs to.
  50544. */
  50545. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50546. /**
  50547. * Binds the material data.
  50548. * @param uniformBuffer defines the Uniform buffer to fill in.
  50549. * @param scene defines the scene the material belongs to.
  50550. * @param isFrozen defines wether the material is frozen or not.
  50551. */
  50552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50553. /**
  50554. * Checks to see if a texture is used in the material.
  50555. * @param texture - Base texture to use.
  50556. * @returns - Boolean specifying if a texture is used in the material.
  50557. */
  50558. hasTexture(texture: BaseTexture): boolean;
  50559. /**
  50560. * Returns an array of the actively used textures.
  50561. * @param activeTextures Array of BaseTextures
  50562. */
  50563. getActiveTextures(activeTextures: BaseTexture[]): void;
  50564. /**
  50565. * Returns the animatable textures.
  50566. * @param animatables Array of animatable textures.
  50567. */
  50568. getAnimatables(animatables: IAnimatable[]): void;
  50569. /**
  50570. * Disposes the resources of the material.
  50571. * @param forceDisposeTextures - Forces the disposal of all textures.
  50572. */
  50573. dispose(forceDisposeTextures?: boolean): void;
  50574. /**
  50575. * Get the current class name of the texture useful for serialization or dynamic coding.
  50576. * @returns "PBRAnisotropicConfiguration"
  50577. */
  50578. getClassName(): string;
  50579. /**
  50580. * Add fallbacks to the effect fallbacks list.
  50581. * @param defines defines the Base texture to use.
  50582. * @param fallbacks defines the current fallback list.
  50583. * @param currentRank defines the current fallback rank.
  50584. * @returns the new fallback rank.
  50585. */
  50586. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50587. /**
  50588. * Add the required uniforms to the current list.
  50589. * @param uniforms defines the current uniform list.
  50590. */
  50591. static AddUniforms(uniforms: string[]): void;
  50592. /**
  50593. * Add the required uniforms to the current buffer.
  50594. * @param uniformBuffer defines the current uniform buffer.
  50595. */
  50596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50597. /**
  50598. * Add the required samplers to the current list.
  50599. * @param samplers defines the current sampler list.
  50600. */
  50601. static AddSamplers(samplers: string[]): void;
  50602. /**
  50603. * Makes a duplicate of the current configuration into another one.
  50604. * @param anisotropicConfiguration define the config where to copy the info
  50605. */
  50606. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50607. /**
  50608. * Serializes this anisotropy configuration.
  50609. * @returns - An object with the serialized config.
  50610. */
  50611. serialize(): any;
  50612. /**
  50613. * Parses a anisotropy Configuration from a serialized object.
  50614. * @param source - Serialized object.
  50615. * @param scene Defines the scene we are parsing for
  50616. * @param rootUrl Defines the rootUrl to load from
  50617. */
  50618. parse(source: any, scene: Scene, rootUrl: string): void;
  50619. }
  50620. }
  50621. declare module BABYLON {
  50622. /**
  50623. * @hidden
  50624. */
  50625. export interface IMaterialBRDFDefines {
  50626. BRDF_V_HEIGHT_CORRELATED: boolean;
  50627. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50628. SPHERICAL_HARMONICS: boolean;
  50629. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50630. /** @hidden */
  50631. _areMiscDirty: boolean;
  50632. }
  50633. /**
  50634. * Define the code related to the BRDF parameters of the pbr material.
  50635. */
  50636. export class PBRBRDFConfiguration {
  50637. /**
  50638. * Default value used for the energy conservation.
  50639. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50640. */
  50641. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50642. /**
  50643. * Default value used for the Smith Visibility Height Correlated mode.
  50644. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50645. */
  50646. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50647. /**
  50648. * Default value used for the IBL diffuse part.
  50649. * This can help switching back to the polynomials mode globally which is a tiny bit
  50650. * less GPU intensive at the drawback of a lower quality.
  50651. */
  50652. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50653. /**
  50654. * Default value used for activating energy conservation for the specular workflow.
  50655. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50656. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50657. */
  50658. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50659. private _useEnergyConservation;
  50660. /**
  50661. * Defines if the material uses energy conservation.
  50662. */
  50663. useEnergyConservation: boolean;
  50664. private _useSmithVisibilityHeightCorrelated;
  50665. /**
  50666. * LEGACY Mode set to false
  50667. * Defines if the material uses height smith correlated visibility term.
  50668. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50669. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50670. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50671. * Not relying on height correlated will also disable energy conservation.
  50672. */
  50673. useSmithVisibilityHeightCorrelated: boolean;
  50674. private _useSphericalHarmonics;
  50675. /**
  50676. * LEGACY Mode set to false
  50677. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50678. * diffuse part of the IBL.
  50679. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50680. * to the ground truth.
  50681. */
  50682. useSphericalHarmonics: boolean;
  50683. private _useSpecularGlossinessInputEnergyConservation;
  50684. /**
  50685. * Defines if the material uses energy conservation, when the specular workflow is active.
  50686. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50687. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50688. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50689. */
  50690. useSpecularGlossinessInputEnergyConservation: boolean;
  50691. /** @hidden */
  50692. private _internalMarkAllSubMeshesAsMiscDirty;
  50693. /** @hidden */
  50694. _markAllSubMeshesAsMiscDirty(): void;
  50695. /**
  50696. * Instantiate a new istance of clear coat configuration.
  50697. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50698. */
  50699. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50700. /**
  50701. * Checks to see if a texture is used in the material.
  50702. * @param defines the list of "defines" to update.
  50703. */
  50704. prepareDefines(defines: IMaterialBRDFDefines): void;
  50705. /**
  50706. * Get the current class name of the texture useful for serialization or dynamic coding.
  50707. * @returns "PBRClearCoatConfiguration"
  50708. */
  50709. getClassName(): string;
  50710. /**
  50711. * Makes a duplicate of the current configuration into another one.
  50712. * @param brdfConfiguration define the config where to copy the info
  50713. */
  50714. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50715. /**
  50716. * Serializes this BRDF configuration.
  50717. * @returns - An object with the serialized config.
  50718. */
  50719. serialize(): any;
  50720. /**
  50721. * Parses a anisotropy Configuration from a serialized object.
  50722. * @param source - Serialized object.
  50723. * @param scene Defines the scene we are parsing for
  50724. * @param rootUrl Defines the rootUrl to load from
  50725. */
  50726. parse(source: any, scene: Scene, rootUrl: string): void;
  50727. }
  50728. }
  50729. declare module BABYLON {
  50730. /**
  50731. * @hidden
  50732. */
  50733. export interface IMaterialSheenDefines {
  50734. SHEEN: boolean;
  50735. SHEEN_TEXTURE: boolean;
  50736. SHEEN_TEXTUREDIRECTUV: number;
  50737. SHEEN_LINKWITHALBEDO: boolean;
  50738. SHEEN_ROUGHNESS: boolean;
  50739. SHEEN_ALBEDOSCALING: boolean;
  50740. /** @hidden */
  50741. _areTexturesDirty: boolean;
  50742. }
  50743. /**
  50744. * Define the code related to the Sheen parameters of the pbr material.
  50745. */
  50746. export class PBRSheenConfiguration {
  50747. private _isEnabled;
  50748. /**
  50749. * Defines if the material uses sheen.
  50750. */
  50751. isEnabled: boolean;
  50752. private _linkSheenWithAlbedo;
  50753. /**
  50754. * Defines if the sheen is linked to the sheen color.
  50755. */
  50756. linkSheenWithAlbedo: boolean;
  50757. /**
  50758. * Defines the sheen intensity.
  50759. */
  50760. intensity: number;
  50761. /**
  50762. * Defines the sheen color.
  50763. */
  50764. color: Color3;
  50765. private _texture;
  50766. /**
  50767. * Stores the sheen tint values in a texture.
  50768. * rgb is tint
  50769. * a is a intensity
  50770. */
  50771. texture: Nullable<BaseTexture>;
  50772. private _roughness;
  50773. /**
  50774. * Defines the sheen roughness.
  50775. * It is not taken into account if linkSheenWithAlbedo is true.
  50776. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50777. */
  50778. roughness: Nullable<number>;
  50779. private _albedoScaling;
  50780. /**
  50781. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50782. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50783. * making it easier to setup and tweak the effect
  50784. */
  50785. albedoScaling: boolean;
  50786. /** @hidden */
  50787. private _internalMarkAllSubMeshesAsTexturesDirty;
  50788. /** @hidden */
  50789. _markAllSubMeshesAsTexturesDirty(): void;
  50790. /**
  50791. * Instantiate a new istance of clear coat configuration.
  50792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50793. */
  50794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50795. /**
  50796. * Specifies that the submesh is ready to be used.
  50797. * @param defines the list of "defines" to update.
  50798. * @param scene defines the scene the material belongs to.
  50799. * @returns - boolean indicating that the submesh is ready or not.
  50800. */
  50801. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50802. /**
  50803. * Checks to see if a texture is used in the material.
  50804. * @param defines the list of "defines" to update.
  50805. * @param scene defines the scene the material belongs to.
  50806. */
  50807. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50808. /**
  50809. * Binds the material data.
  50810. * @param uniformBuffer defines the Uniform buffer to fill in.
  50811. * @param scene defines the scene the material belongs to.
  50812. * @param isFrozen defines wether the material is frozen or not.
  50813. */
  50814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50815. /**
  50816. * Checks to see if a texture is used in the material.
  50817. * @param texture - Base texture to use.
  50818. * @returns - Boolean specifying if a texture is used in the material.
  50819. */
  50820. hasTexture(texture: BaseTexture): boolean;
  50821. /**
  50822. * Returns an array of the actively used textures.
  50823. * @param activeTextures Array of BaseTextures
  50824. */
  50825. getActiveTextures(activeTextures: BaseTexture[]): void;
  50826. /**
  50827. * Returns the animatable textures.
  50828. * @param animatables Array of animatable textures.
  50829. */
  50830. getAnimatables(animatables: IAnimatable[]): void;
  50831. /**
  50832. * Disposes the resources of the material.
  50833. * @param forceDisposeTextures - Forces the disposal of all textures.
  50834. */
  50835. dispose(forceDisposeTextures?: boolean): void;
  50836. /**
  50837. * Get the current class name of the texture useful for serialization or dynamic coding.
  50838. * @returns "PBRSheenConfiguration"
  50839. */
  50840. getClassName(): string;
  50841. /**
  50842. * Add fallbacks to the effect fallbacks list.
  50843. * @param defines defines the Base texture to use.
  50844. * @param fallbacks defines the current fallback list.
  50845. * @param currentRank defines the current fallback rank.
  50846. * @returns the new fallback rank.
  50847. */
  50848. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50849. /**
  50850. * Add the required uniforms to the current list.
  50851. * @param uniforms defines the current uniform list.
  50852. */
  50853. static AddUniforms(uniforms: string[]): void;
  50854. /**
  50855. * Add the required uniforms to the current buffer.
  50856. * @param uniformBuffer defines the current uniform buffer.
  50857. */
  50858. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50859. /**
  50860. * Add the required samplers to the current list.
  50861. * @param samplers defines the current sampler list.
  50862. */
  50863. static AddSamplers(samplers: string[]): void;
  50864. /**
  50865. * Makes a duplicate of the current configuration into another one.
  50866. * @param sheenConfiguration define the config where to copy the info
  50867. */
  50868. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50869. /**
  50870. * Serializes this BRDF configuration.
  50871. * @returns - An object with the serialized config.
  50872. */
  50873. serialize(): any;
  50874. /**
  50875. * Parses a anisotropy Configuration from a serialized object.
  50876. * @param source - Serialized object.
  50877. * @param scene Defines the scene we are parsing for
  50878. * @param rootUrl Defines the rootUrl to load from
  50879. */
  50880. parse(source: any, scene: Scene, rootUrl: string): void;
  50881. }
  50882. }
  50883. declare module BABYLON {
  50884. /**
  50885. * @hidden
  50886. */
  50887. export interface IMaterialSubSurfaceDefines {
  50888. SUBSURFACE: boolean;
  50889. SS_REFRACTION: boolean;
  50890. SS_TRANSLUCENCY: boolean;
  50891. SS_SCATERRING: boolean;
  50892. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50893. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50894. SS_REFRACTIONMAP_3D: boolean;
  50895. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50896. SS_LODINREFRACTIONALPHA: boolean;
  50897. SS_GAMMAREFRACTION: boolean;
  50898. SS_RGBDREFRACTION: boolean;
  50899. SS_LINEARSPECULARREFRACTION: boolean;
  50900. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50901. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50902. /** @hidden */
  50903. _areTexturesDirty: boolean;
  50904. }
  50905. /**
  50906. * Define the code related to the sub surface parameters of the pbr material.
  50907. */
  50908. export class PBRSubSurfaceConfiguration {
  50909. private _isRefractionEnabled;
  50910. /**
  50911. * Defines if the refraction is enabled in the material.
  50912. */
  50913. isRefractionEnabled: boolean;
  50914. private _isTranslucencyEnabled;
  50915. /**
  50916. * Defines if the translucency is enabled in the material.
  50917. */
  50918. isTranslucencyEnabled: boolean;
  50919. private _isScatteringEnabled;
  50920. /**
  50921. * Defines the refraction intensity of the material.
  50922. * The refraction when enabled replaces the Diffuse part of the material.
  50923. * The intensity helps transitionning between diffuse and refraction.
  50924. */
  50925. refractionIntensity: number;
  50926. /**
  50927. * Defines the translucency intensity of the material.
  50928. * When translucency has been enabled, this defines how much of the "translucency"
  50929. * is addded to the diffuse part of the material.
  50930. */
  50931. translucencyIntensity: number;
  50932. /**
  50933. * Defines the scattering intensity of the material.
  50934. * When scattering has been enabled, this defines how much of the "scattered light"
  50935. * is addded to the diffuse part of the material.
  50936. */
  50937. scatteringIntensity: number;
  50938. private _thicknessTexture;
  50939. /**
  50940. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50941. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50942. * 0 would mean minimumThickness
  50943. * 1 would mean maximumThickness
  50944. * The other channels might be use as a mask to vary the different effects intensity.
  50945. */
  50946. thicknessTexture: Nullable<BaseTexture>;
  50947. private _refractionTexture;
  50948. /**
  50949. * Defines the texture to use for refraction.
  50950. */
  50951. refractionTexture: Nullable<BaseTexture>;
  50952. private _indexOfRefraction;
  50953. /**
  50954. * Defines the index of refraction used in the material.
  50955. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50956. */
  50957. indexOfRefraction: number;
  50958. private _invertRefractionY;
  50959. /**
  50960. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50961. */
  50962. invertRefractionY: boolean;
  50963. private _linkRefractionWithTransparency;
  50964. /**
  50965. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50966. * Materials half opaque for instance using refraction could benefit from this control.
  50967. */
  50968. linkRefractionWithTransparency: boolean;
  50969. /**
  50970. * Defines the minimum thickness stored in the thickness map.
  50971. * If no thickness map is defined, this value will be used to simulate thickness.
  50972. */
  50973. minimumThickness: number;
  50974. /**
  50975. * Defines the maximum thickness stored in the thickness map.
  50976. */
  50977. maximumThickness: number;
  50978. /**
  50979. * Defines the volume tint of the material.
  50980. * This is used for both translucency and scattering.
  50981. */
  50982. tintColor: Color3;
  50983. /**
  50984. * Defines the distance at which the tint color should be found in the media.
  50985. * This is used for refraction only.
  50986. */
  50987. tintColorAtDistance: number;
  50988. /**
  50989. * Defines how far each channel transmit through the media.
  50990. * It is defined as a color to simplify it selection.
  50991. */
  50992. diffusionDistance: Color3;
  50993. private _useMaskFromThicknessTexture;
  50994. /**
  50995. * Stores the intensity of the different subsurface effects in the thickness texture.
  50996. * * the green channel is the translucency intensity.
  50997. * * the blue channel is the scattering intensity.
  50998. * * the alpha channel is the refraction intensity.
  50999. */
  51000. useMaskFromThicknessTexture: boolean;
  51001. /** @hidden */
  51002. private _internalMarkAllSubMeshesAsTexturesDirty;
  51003. /** @hidden */
  51004. _markAllSubMeshesAsTexturesDirty(): void;
  51005. /**
  51006. * Instantiate a new istance of sub surface configuration.
  51007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51008. */
  51009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51010. /**
  51011. * Gets wehter the submesh is ready to be used or not.
  51012. * @param defines the list of "defines" to update.
  51013. * @param scene defines the scene the material belongs to.
  51014. * @returns - boolean indicating that the submesh is ready or not.
  51015. */
  51016. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51017. /**
  51018. * Checks to see if a texture is used in the material.
  51019. * @param defines the list of "defines" to update.
  51020. * @param scene defines the scene to the material belongs to.
  51021. */
  51022. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51023. /**
  51024. * Binds the material data.
  51025. * @param uniformBuffer defines the Uniform buffer to fill in.
  51026. * @param scene defines the scene the material belongs to.
  51027. * @param engine defines the engine the material belongs to.
  51028. * @param isFrozen defines wether the material is frozen or not.
  51029. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51030. */
  51031. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51032. /**
  51033. * Unbinds the material from the mesh.
  51034. * @param activeEffect defines the effect that should be unbound from.
  51035. * @returns true if unbound, otherwise false
  51036. */
  51037. unbind(activeEffect: Effect): boolean;
  51038. /**
  51039. * Returns the texture used for refraction or null if none is used.
  51040. * @param scene defines the scene the material belongs to.
  51041. * @returns - Refraction texture if present. If no refraction texture and refraction
  51042. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51043. */
  51044. private _getRefractionTexture;
  51045. /**
  51046. * Returns true if alpha blending should be disabled.
  51047. */
  51048. get disableAlphaBlending(): boolean;
  51049. /**
  51050. * Fills the list of render target textures.
  51051. * @param renderTargets the list of render targets to update
  51052. */
  51053. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51054. /**
  51055. * Checks to see if a texture is used in the material.
  51056. * @param texture - Base texture to use.
  51057. * @returns - Boolean specifying if a texture is used in the material.
  51058. */
  51059. hasTexture(texture: BaseTexture): boolean;
  51060. /**
  51061. * Gets a boolean indicating that current material needs to register RTT
  51062. * @returns true if this uses a render target otherwise false.
  51063. */
  51064. hasRenderTargetTextures(): boolean;
  51065. /**
  51066. * Returns an array of the actively used textures.
  51067. * @param activeTextures Array of BaseTextures
  51068. */
  51069. getActiveTextures(activeTextures: BaseTexture[]): void;
  51070. /**
  51071. * Returns the animatable textures.
  51072. * @param animatables Array of animatable textures.
  51073. */
  51074. getAnimatables(animatables: IAnimatable[]): void;
  51075. /**
  51076. * Disposes the resources of the material.
  51077. * @param forceDisposeTextures - Forces the disposal of all textures.
  51078. */
  51079. dispose(forceDisposeTextures?: boolean): void;
  51080. /**
  51081. * Get the current class name of the texture useful for serialization or dynamic coding.
  51082. * @returns "PBRSubSurfaceConfiguration"
  51083. */
  51084. getClassName(): string;
  51085. /**
  51086. * Add fallbacks to the effect fallbacks list.
  51087. * @param defines defines the Base texture to use.
  51088. * @param fallbacks defines the current fallback list.
  51089. * @param currentRank defines the current fallback rank.
  51090. * @returns the new fallback rank.
  51091. */
  51092. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51093. /**
  51094. * Add the required uniforms to the current list.
  51095. * @param uniforms defines the current uniform list.
  51096. */
  51097. static AddUniforms(uniforms: string[]): void;
  51098. /**
  51099. * Add the required samplers to the current list.
  51100. * @param samplers defines the current sampler list.
  51101. */
  51102. static AddSamplers(samplers: string[]): void;
  51103. /**
  51104. * Add the required uniforms to the current buffer.
  51105. * @param uniformBuffer defines the current uniform buffer.
  51106. */
  51107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51108. /**
  51109. * Makes a duplicate of the current configuration into another one.
  51110. * @param configuration define the config where to copy the info
  51111. */
  51112. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51113. /**
  51114. * Serializes this Sub Surface configuration.
  51115. * @returns - An object with the serialized config.
  51116. */
  51117. serialize(): any;
  51118. /**
  51119. * Parses a anisotropy Configuration from a serialized object.
  51120. * @param source - Serialized object.
  51121. * @param scene Defines the scene we are parsing for
  51122. * @param rootUrl Defines the rootUrl to load from
  51123. */
  51124. parse(source: any, scene: Scene, rootUrl: string): void;
  51125. }
  51126. }
  51127. declare module BABYLON {
  51128. /** @hidden */
  51129. export var pbrFragmentDeclaration: {
  51130. name: string;
  51131. shader: string;
  51132. };
  51133. }
  51134. declare module BABYLON {
  51135. /** @hidden */
  51136. export var pbrUboDeclaration: {
  51137. name: string;
  51138. shader: string;
  51139. };
  51140. }
  51141. declare module BABYLON {
  51142. /** @hidden */
  51143. export var pbrFragmentExtraDeclaration: {
  51144. name: string;
  51145. shader: string;
  51146. };
  51147. }
  51148. declare module BABYLON {
  51149. /** @hidden */
  51150. export var pbrFragmentSamplersDeclaration: {
  51151. name: string;
  51152. shader: string;
  51153. };
  51154. }
  51155. declare module BABYLON {
  51156. /** @hidden */
  51157. export var pbrHelperFunctions: {
  51158. name: string;
  51159. shader: string;
  51160. };
  51161. }
  51162. declare module BABYLON {
  51163. /** @hidden */
  51164. export var harmonicsFunctions: {
  51165. name: string;
  51166. shader: string;
  51167. };
  51168. }
  51169. declare module BABYLON {
  51170. /** @hidden */
  51171. export var pbrDirectLightingSetupFunctions: {
  51172. name: string;
  51173. shader: string;
  51174. };
  51175. }
  51176. declare module BABYLON {
  51177. /** @hidden */
  51178. export var pbrDirectLightingFalloffFunctions: {
  51179. name: string;
  51180. shader: string;
  51181. };
  51182. }
  51183. declare module BABYLON {
  51184. /** @hidden */
  51185. export var pbrBRDFFunctions: {
  51186. name: string;
  51187. shader: string;
  51188. };
  51189. }
  51190. declare module BABYLON {
  51191. /** @hidden */
  51192. export var pbrDirectLightingFunctions: {
  51193. name: string;
  51194. shader: string;
  51195. };
  51196. }
  51197. declare module BABYLON {
  51198. /** @hidden */
  51199. export var pbrIBLFunctions: {
  51200. name: string;
  51201. shader: string;
  51202. };
  51203. }
  51204. declare module BABYLON {
  51205. /** @hidden */
  51206. export var pbrDebug: {
  51207. name: string;
  51208. shader: string;
  51209. };
  51210. }
  51211. declare module BABYLON {
  51212. /** @hidden */
  51213. export var pbrPixelShader: {
  51214. name: string;
  51215. shader: string;
  51216. };
  51217. }
  51218. declare module BABYLON {
  51219. /** @hidden */
  51220. export var pbrVertexDeclaration: {
  51221. name: string;
  51222. shader: string;
  51223. };
  51224. }
  51225. declare module BABYLON {
  51226. /** @hidden */
  51227. export var pbrVertexShader: {
  51228. name: string;
  51229. shader: string;
  51230. };
  51231. }
  51232. declare module BABYLON {
  51233. /**
  51234. * Manages the defines for the PBR Material.
  51235. * @hidden
  51236. */
  51237. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51238. PBR: boolean;
  51239. MAINUV1: boolean;
  51240. MAINUV2: boolean;
  51241. UV1: boolean;
  51242. UV2: boolean;
  51243. ALBEDO: boolean;
  51244. GAMMAALBEDO: boolean;
  51245. ALBEDODIRECTUV: number;
  51246. VERTEXCOLOR: boolean;
  51247. AMBIENT: boolean;
  51248. AMBIENTDIRECTUV: number;
  51249. AMBIENTINGRAYSCALE: boolean;
  51250. OPACITY: boolean;
  51251. VERTEXALPHA: boolean;
  51252. OPACITYDIRECTUV: number;
  51253. OPACITYRGB: boolean;
  51254. ALPHATEST: boolean;
  51255. DEPTHPREPASS: boolean;
  51256. ALPHABLEND: boolean;
  51257. ALPHAFROMALBEDO: boolean;
  51258. ALPHATESTVALUE: string;
  51259. SPECULAROVERALPHA: boolean;
  51260. RADIANCEOVERALPHA: boolean;
  51261. ALPHAFRESNEL: boolean;
  51262. LINEARALPHAFRESNEL: boolean;
  51263. PREMULTIPLYALPHA: boolean;
  51264. EMISSIVE: boolean;
  51265. EMISSIVEDIRECTUV: number;
  51266. REFLECTIVITY: boolean;
  51267. REFLECTIVITYDIRECTUV: number;
  51268. SPECULARTERM: boolean;
  51269. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51270. MICROSURFACEAUTOMATIC: boolean;
  51271. LODBASEDMICROSFURACE: boolean;
  51272. MICROSURFACEMAP: boolean;
  51273. MICROSURFACEMAPDIRECTUV: number;
  51274. METALLICWORKFLOW: boolean;
  51275. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51276. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51277. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51278. AOSTOREINMETALMAPRED: boolean;
  51279. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51280. ENVIRONMENTBRDF: boolean;
  51281. ENVIRONMENTBRDF_RGBD: boolean;
  51282. NORMAL: boolean;
  51283. TANGENT: boolean;
  51284. BUMP: boolean;
  51285. BUMPDIRECTUV: number;
  51286. OBJECTSPACE_NORMALMAP: boolean;
  51287. PARALLAX: boolean;
  51288. PARALLAXOCCLUSION: boolean;
  51289. NORMALXYSCALE: boolean;
  51290. LIGHTMAP: boolean;
  51291. LIGHTMAPDIRECTUV: number;
  51292. USELIGHTMAPASSHADOWMAP: boolean;
  51293. GAMMALIGHTMAP: boolean;
  51294. RGBDLIGHTMAP: boolean;
  51295. REFLECTION: boolean;
  51296. REFLECTIONMAP_3D: boolean;
  51297. REFLECTIONMAP_SPHERICAL: boolean;
  51298. REFLECTIONMAP_PLANAR: boolean;
  51299. REFLECTIONMAP_CUBIC: boolean;
  51300. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51301. REFLECTIONMAP_PROJECTION: boolean;
  51302. REFLECTIONMAP_SKYBOX: boolean;
  51303. REFLECTIONMAP_EXPLICIT: boolean;
  51304. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51305. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51306. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51307. INVERTCUBICMAP: boolean;
  51308. USESPHERICALFROMREFLECTIONMAP: boolean;
  51309. USEIRRADIANCEMAP: boolean;
  51310. SPHERICAL_HARMONICS: boolean;
  51311. USESPHERICALINVERTEX: boolean;
  51312. REFLECTIONMAP_OPPOSITEZ: boolean;
  51313. LODINREFLECTIONALPHA: boolean;
  51314. GAMMAREFLECTION: boolean;
  51315. RGBDREFLECTION: boolean;
  51316. LINEARSPECULARREFLECTION: boolean;
  51317. RADIANCEOCCLUSION: boolean;
  51318. HORIZONOCCLUSION: boolean;
  51319. INSTANCES: boolean;
  51320. NUM_BONE_INFLUENCERS: number;
  51321. BonesPerMesh: number;
  51322. BONETEXTURE: boolean;
  51323. NONUNIFORMSCALING: boolean;
  51324. MORPHTARGETS: boolean;
  51325. MORPHTARGETS_NORMAL: boolean;
  51326. MORPHTARGETS_TANGENT: boolean;
  51327. MORPHTARGETS_UV: boolean;
  51328. NUM_MORPH_INFLUENCERS: number;
  51329. IMAGEPROCESSING: boolean;
  51330. VIGNETTE: boolean;
  51331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51332. VIGNETTEBLENDMODEOPAQUE: boolean;
  51333. TONEMAPPING: boolean;
  51334. TONEMAPPING_ACES: boolean;
  51335. CONTRAST: boolean;
  51336. COLORCURVES: boolean;
  51337. COLORGRADING: boolean;
  51338. COLORGRADING3D: boolean;
  51339. SAMPLER3DGREENDEPTH: boolean;
  51340. SAMPLER3DBGRMAP: boolean;
  51341. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51342. EXPOSURE: boolean;
  51343. MULTIVIEW: boolean;
  51344. USEPHYSICALLIGHTFALLOFF: boolean;
  51345. USEGLTFLIGHTFALLOFF: boolean;
  51346. TWOSIDEDLIGHTING: boolean;
  51347. SHADOWFLOAT: boolean;
  51348. CLIPPLANE: boolean;
  51349. CLIPPLANE2: boolean;
  51350. CLIPPLANE3: boolean;
  51351. CLIPPLANE4: boolean;
  51352. CLIPPLANE5: boolean;
  51353. CLIPPLANE6: boolean;
  51354. POINTSIZE: boolean;
  51355. FOG: boolean;
  51356. LOGARITHMICDEPTH: boolean;
  51357. FORCENORMALFORWARD: boolean;
  51358. SPECULARAA: boolean;
  51359. CLEARCOAT: boolean;
  51360. CLEARCOAT_DEFAULTIOR: boolean;
  51361. CLEARCOAT_TEXTURE: boolean;
  51362. CLEARCOAT_TEXTUREDIRECTUV: number;
  51363. CLEARCOAT_BUMP: boolean;
  51364. CLEARCOAT_BUMPDIRECTUV: number;
  51365. CLEARCOAT_TINT: boolean;
  51366. CLEARCOAT_TINT_TEXTURE: boolean;
  51367. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51368. ANISOTROPIC: boolean;
  51369. ANISOTROPIC_TEXTURE: boolean;
  51370. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51371. BRDF_V_HEIGHT_CORRELATED: boolean;
  51372. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51373. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51374. SHEEN: boolean;
  51375. SHEEN_TEXTURE: boolean;
  51376. SHEEN_TEXTUREDIRECTUV: number;
  51377. SHEEN_LINKWITHALBEDO: boolean;
  51378. SHEEN_ROUGHNESS: boolean;
  51379. SHEEN_ALBEDOSCALING: boolean;
  51380. SUBSURFACE: boolean;
  51381. SS_REFRACTION: boolean;
  51382. SS_TRANSLUCENCY: boolean;
  51383. SS_SCATERRING: boolean;
  51384. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51385. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51386. SS_REFRACTIONMAP_3D: boolean;
  51387. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51388. SS_LODINREFRACTIONALPHA: boolean;
  51389. SS_GAMMAREFRACTION: boolean;
  51390. SS_RGBDREFRACTION: boolean;
  51391. SS_LINEARSPECULARREFRACTION: boolean;
  51392. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51393. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51394. UNLIT: boolean;
  51395. DEBUGMODE: number;
  51396. /**
  51397. * Initializes the PBR Material defines.
  51398. */
  51399. constructor();
  51400. /**
  51401. * Resets the PBR Material defines.
  51402. */
  51403. reset(): void;
  51404. }
  51405. /**
  51406. * The Physically based material base class of BJS.
  51407. *
  51408. * This offers the main features of a standard PBR material.
  51409. * For more information, please refer to the documentation :
  51410. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51411. */
  51412. export abstract class PBRBaseMaterial extends PushMaterial {
  51413. /**
  51414. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51415. */
  51416. static readonly PBRMATERIAL_OPAQUE: number;
  51417. /**
  51418. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51419. */
  51420. static readonly PBRMATERIAL_ALPHATEST: number;
  51421. /**
  51422. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51423. */
  51424. static readonly PBRMATERIAL_ALPHABLEND: number;
  51425. /**
  51426. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51427. * They are also discarded below the alpha cutoff threshold to improve performances.
  51428. */
  51429. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51430. /**
  51431. * Defines the default value of how much AO map is occluding the analytical lights
  51432. * (point spot...).
  51433. */
  51434. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51435. /**
  51436. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51437. */
  51438. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51439. /**
  51440. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51441. * to enhance interoperability with other engines.
  51442. */
  51443. static readonly LIGHTFALLOFF_GLTF: number;
  51444. /**
  51445. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51446. * to enhance interoperability with other materials.
  51447. */
  51448. static readonly LIGHTFALLOFF_STANDARD: number;
  51449. /**
  51450. * Intensity of the direct lights e.g. the four lights available in your scene.
  51451. * This impacts both the direct diffuse and specular highlights.
  51452. */
  51453. protected _directIntensity: number;
  51454. /**
  51455. * Intensity of the emissive part of the material.
  51456. * This helps controlling the emissive effect without modifying the emissive color.
  51457. */
  51458. protected _emissiveIntensity: number;
  51459. /**
  51460. * Intensity of the environment e.g. how much the environment will light the object
  51461. * either through harmonics for rough material or through the refelction for shiny ones.
  51462. */
  51463. protected _environmentIntensity: number;
  51464. /**
  51465. * This is a special control allowing the reduction of the specular highlights coming from the
  51466. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51467. */
  51468. protected _specularIntensity: number;
  51469. /**
  51470. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51471. */
  51472. private _lightingInfos;
  51473. /**
  51474. * Debug Control allowing disabling the bump map on this material.
  51475. */
  51476. protected _disableBumpMap: boolean;
  51477. /**
  51478. * AKA Diffuse Texture in standard nomenclature.
  51479. */
  51480. protected _albedoTexture: Nullable<BaseTexture>;
  51481. /**
  51482. * AKA Occlusion Texture in other nomenclature.
  51483. */
  51484. protected _ambientTexture: Nullable<BaseTexture>;
  51485. /**
  51486. * AKA Occlusion Texture Intensity in other nomenclature.
  51487. */
  51488. protected _ambientTextureStrength: number;
  51489. /**
  51490. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51491. * 1 means it completely occludes it
  51492. * 0 mean it has no impact
  51493. */
  51494. protected _ambientTextureImpactOnAnalyticalLights: number;
  51495. /**
  51496. * Stores the alpha values in a texture.
  51497. */
  51498. protected _opacityTexture: Nullable<BaseTexture>;
  51499. /**
  51500. * Stores the reflection values in a texture.
  51501. */
  51502. protected _reflectionTexture: Nullable<BaseTexture>;
  51503. /**
  51504. * Stores the emissive values in a texture.
  51505. */
  51506. protected _emissiveTexture: Nullable<BaseTexture>;
  51507. /**
  51508. * AKA Specular texture in other nomenclature.
  51509. */
  51510. protected _reflectivityTexture: Nullable<BaseTexture>;
  51511. /**
  51512. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51513. */
  51514. protected _metallicTexture: Nullable<BaseTexture>;
  51515. /**
  51516. * Specifies the metallic scalar of the metallic/roughness workflow.
  51517. * Can also be used to scale the metalness values of the metallic texture.
  51518. */
  51519. protected _metallic: Nullable<number>;
  51520. /**
  51521. * Specifies the roughness scalar of the metallic/roughness workflow.
  51522. * Can also be used to scale the roughness values of the metallic texture.
  51523. */
  51524. protected _roughness: Nullable<number>;
  51525. /**
  51526. * Specifies the an F0 factor to help configuring the material F0.
  51527. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51528. * to 0.5 the previously hard coded value stays the same.
  51529. * Can also be used to scale the F0 values of the metallic texture.
  51530. */
  51531. protected _metallicF0Factor: number;
  51532. /**
  51533. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51534. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51535. * your expectation as it multiplies with the texture data.
  51536. */
  51537. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51538. /**
  51539. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51540. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51541. */
  51542. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51543. /**
  51544. * Stores surface normal data used to displace a mesh in a texture.
  51545. */
  51546. protected _bumpTexture: Nullable<BaseTexture>;
  51547. /**
  51548. * Stores the pre-calculated light information of a mesh in a texture.
  51549. */
  51550. protected _lightmapTexture: Nullable<BaseTexture>;
  51551. /**
  51552. * The color of a material in ambient lighting.
  51553. */
  51554. protected _ambientColor: Color3;
  51555. /**
  51556. * AKA Diffuse Color in other nomenclature.
  51557. */
  51558. protected _albedoColor: Color3;
  51559. /**
  51560. * AKA Specular Color in other nomenclature.
  51561. */
  51562. protected _reflectivityColor: Color3;
  51563. /**
  51564. * The color applied when light is reflected from a material.
  51565. */
  51566. protected _reflectionColor: Color3;
  51567. /**
  51568. * The color applied when light is emitted from a material.
  51569. */
  51570. protected _emissiveColor: Color3;
  51571. /**
  51572. * AKA Glossiness in other nomenclature.
  51573. */
  51574. protected _microSurface: number;
  51575. /**
  51576. * Specifies that the material will use the light map as a show map.
  51577. */
  51578. protected _useLightmapAsShadowmap: boolean;
  51579. /**
  51580. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51581. * makes the reflect vector face the model (under horizon).
  51582. */
  51583. protected _useHorizonOcclusion: boolean;
  51584. /**
  51585. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51586. * too much the area relying on ambient texture to define their ambient occlusion.
  51587. */
  51588. protected _useRadianceOcclusion: boolean;
  51589. /**
  51590. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51591. */
  51592. protected _useAlphaFromAlbedoTexture: boolean;
  51593. /**
  51594. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51595. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51596. */
  51597. protected _useSpecularOverAlpha: boolean;
  51598. /**
  51599. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51600. */
  51601. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51602. /**
  51603. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51604. */
  51605. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51606. /**
  51607. * Specifies if the metallic texture contains the roughness information in its green channel.
  51608. */
  51609. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51610. /**
  51611. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51612. */
  51613. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51614. /**
  51615. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51616. */
  51617. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51618. /**
  51619. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51620. */
  51621. protected _useAmbientInGrayScale: boolean;
  51622. /**
  51623. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51624. * The material will try to infer what glossiness each pixel should be.
  51625. */
  51626. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51627. /**
  51628. * Defines the falloff type used in this material.
  51629. * It by default is Physical.
  51630. */
  51631. protected _lightFalloff: number;
  51632. /**
  51633. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51634. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51635. */
  51636. protected _useRadianceOverAlpha: boolean;
  51637. /**
  51638. * Allows using an object space normal map (instead of tangent space).
  51639. */
  51640. protected _useObjectSpaceNormalMap: boolean;
  51641. /**
  51642. * Allows using the bump map in parallax mode.
  51643. */
  51644. protected _useParallax: boolean;
  51645. /**
  51646. * Allows using the bump map in parallax occlusion mode.
  51647. */
  51648. protected _useParallaxOcclusion: boolean;
  51649. /**
  51650. * Controls the scale bias of the parallax mode.
  51651. */
  51652. protected _parallaxScaleBias: number;
  51653. /**
  51654. * If sets to true, disables all the lights affecting the material.
  51655. */
  51656. protected _disableLighting: boolean;
  51657. /**
  51658. * Number of Simultaneous lights allowed on the material.
  51659. */
  51660. protected _maxSimultaneousLights: number;
  51661. /**
  51662. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51663. */
  51664. protected _invertNormalMapX: boolean;
  51665. /**
  51666. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51667. */
  51668. protected _invertNormalMapY: boolean;
  51669. /**
  51670. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51671. */
  51672. protected _twoSidedLighting: boolean;
  51673. /**
  51674. * Defines the alpha limits in alpha test mode.
  51675. */
  51676. protected _alphaCutOff: number;
  51677. /**
  51678. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51679. */
  51680. protected _forceAlphaTest: boolean;
  51681. /**
  51682. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51683. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51684. */
  51685. protected _useAlphaFresnel: boolean;
  51686. /**
  51687. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51688. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51689. */
  51690. protected _useLinearAlphaFresnel: boolean;
  51691. /**
  51692. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51693. * from cos thetav and roughness:
  51694. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51695. */
  51696. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51697. /**
  51698. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51699. */
  51700. protected _forceIrradianceInFragment: boolean;
  51701. /**
  51702. * Force normal to face away from face.
  51703. */
  51704. protected _forceNormalForward: boolean;
  51705. /**
  51706. * Enables specular anti aliasing in the PBR shader.
  51707. * It will both interacts on the Geometry for analytical and IBL lighting.
  51708. * It also prefilter the roughness map based on the bump values.
  51709. */
  51710. protected _enableSpecularAntiAliasing: boolean;
  51711. /**
  51712. * Default configuration related to image processing available in the PBR Material.
  51713. */
  51714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51715. /**
  51716. * Keep track of the image processing observer to allow dispose and replace.
  51717. */
  51718. private _imageProcessingObserver;
  51719. /**
  51720. * Attaches a new image processing configuration to the PBR Material.
  51721. * @param configuration
  51722. */
  51723. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51724. /**
  51725. * Stores the available render targets.
  51726. */
  51727. private _renderTargets;
  51728. /**
  51729. * Sets the global ambient color for the material used in lighting calculations.
  51730. */
  51731. private _globalAmbientColor;
  51732. /**
  51733. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51734. */
  51735. private _useLogarithmicDepth;
  51736. /**
  51737. * If set to true, no lighting calculations will be applied.
  51738. */
  51739. private _unlit;
  51740. private _debugMode;
  51741. /**
  51742. * @hidden
  51743. * This is reserved for the inspector.
  51744. * Defines the material debug mode.
  51745. * It helps seeing only some components of the material while troubleshooting.
  51746. */
  51747. debugMode: number;
  51748. /**
  51749. * @hidden
  51750. * This is reserved for the inspector.
  51751. * Specify from where on screen the debug mode should start.
  51752. * The value goes from -1 (full screen) to 1 (not visible)
  51753. * It helps with side by side comparison against the final render
  51754. * This defaults to -1
  51755. */
  51756. private debugLimit;
  51757. /**
  51758. * @hidden
  51759. * This is reserved for the inspector.
  51760. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51761. * You can use the factor to better multiply the final value.
  51762. */
  51763. private debugFactor;
  51764. /**
  51765. * Defines the clear coat layer parameters for the material.
  51766. */
  51767. readonly clearCoat: PBRClearCoatConfiguration;
  51768. /**
  51769. * Defines the anisotropic parameters for the material.
  51770. */
  51771. readonly anisotropy: PBRAnisotropicConfiguration;
  51772. /**
  51773. * Defines the BRDF parameters for the material.
  51774. */
  51775. readonly brdf: PBRBRDFConfiguration;
  51776. /**
  51777. * Defines the Sheen parameters for the material.
  51778. */
  51779. readonly sheen: PBRSheenConfiguration;
  51780. /**
  51781. * Defines the SubSurface parameters for the material.
  51782. */
  51783. readonly subSurface: PBRSubSurfaceConfiguration;
  51784. /**
  51785. * Custom callback helping to override the default shader used in the material.
  51786. */
  51787. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51788. protected _rebuildInParallel: boolean;
  51789. /**
  51790. * Instantiates a new PBRMaterial instance.
  51791. *
  51792. * @param name The material name
  51793. * @param scene The scene the material will be use in.
  51794. */
  51795. constructor(name: string, scene: Scene);
  51796. /**
  51797. * Gets a boolean indicating that current material needs to register RTT
  51798. */
  51799. get hasRenderTargetTextures(): boolean;
  51800. /**
  51801. * Gets the name of the material class.
  51802. */
  51803. getClassName(): string;
  51804. /**
  51805. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51806. */
  51807. get useLogarithmicDepth(): boolean;
  51808. /**
  51809. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51810. */
  51811. set useLogarithmicDepth(value: boolean);
  51812. /**
  51813. * Returns true if alpha blending should be disabled.
  51814. */
  51815. protected get _disableAlphaBlending(): boolean;
  51816. /**
  51817. * Specifies whether or not this material should be rendered in alpha blend mode.
  51818. */
  51819. needAlphaBlending(): boolean;
  51820. /**
  51821. * Specifies whether or not this material should be rendered in alpha test mode.
  51822. */
  51823. needAlphaTesting(): boolean;
  51824. /**
  51825. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51826. */
  51827. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51828. /**
  51829. * Gets the texture used for the alpha test.
  51830. */
  51831. getAlphaTestTexture(): Nullable<BaseTexture>;
  51832. /**
  51833. * Specifies that the submesh is ready to be used.
  51834. * @param mesh - BJS mesh.
  51835. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51836. * @param useInstances - Specifies that instances should be used.
  51837. * @returns - boolean indicating that the submesh is ready or not.
  51838. */
  51839. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51840. /**
  51841. * Specifies if the material uses metallic roughness workflow.
  51842. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51843. */
  51844. isMetallicWorkflow(): boolean;
  51845. private _prepareEffect;
  51846. private _prepareDefines;
  51847. /**
  51848. * Force shader compilation
  51849. */
  51850. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51851. /**
  51852. * Initializes the uniform buffer layout for the shader.
  51853. */
  51854. buildUniformLayout(): void;
  51855. /**
  51856. * Unbinds the material from the mesh
  51857. */
  51858. unbind(): void;
  51859. /**
  51860. * Binds the submesh data.
  51861. * @param world - The world matrix.
  51862. * @param mesh - The BJS mesh.
  51863. * @param subMesh - A submesh of the BJS mesh.
  51864. */
  51865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51866. /**
  51867. * Returns the animatable textures.
  51868. * @returns - Array of animatable textures.
  51869. */
  51870. getAnimatables(): IAnimatable[];
  51871. /**
  51872. * Returns the texture used for reflections.
  51873. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51874. */
  51875. private _getReflectionTexture;
  51876. /**
  51877. * Returns an array of the actively used textures.
  51878. * @returns - Array of BaseTextures
  51879. */
  51880. getActiveTextures(): BaseTexture[];
  51881. /**
  51882. * Checks to see if a texture is used in the material.
  51883. * @param texture - Base texture to use.
  51884. * @returns - Boolean specifying if a texture is used in the material.
  51885. */
  51886. hasTexture(texture: BaseTexture): boolean;
  51887. /**
  51888. * Disposes the resources of the material.
  51889. * @param forceDisposeEffect - Forces the disposal of effects.
  51890. * @param forceDisposeTextures - Forces the disposal of all textures.
  51891. */
  51892. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51893. }
  51894. }
  51895. declare module BABYLON {
  51896. /**
  51897. * The Physically based material of BJS.
  51898. *
  51899. * This offers the main features of a standard PBR material.
  51900. * For more information, please refer to the documentation :
  51901. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51902. */
  51903. export class PBRMaterial extends PBRBaseMaterial {
  51904. /**
  51905. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51906. */
  51907. static readonly PBRMATERIAL_OPAQUE: number;
  51908. /**
  51909. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51910. */
  51911. static readonly PBRMATERIAL_ALPHATEST: number;
  51912. /**
  51913. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51914. */
  51915. static readonly PBRMATERIAL_ALPHABLEND: number;
  51916. /**
  51917. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51918. * They are also discarded below the alpha cutoff threshold to improve performances.
  51919. */
  51920. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51921. /**
  51922. * Defines the default value of how much AO map is occluding the analytical lights
  51923. * (point spot...).
  51924. */
  51925. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51926. /**
  51927. * Intensity of the direct lights e.g. the four lights available in your scene.
  51928. * This impacts both the direct diffuse and specular highlights.
  51929. */
  51930. directIntensity: number;
  51931. /**
  51932. * Intensity of the emissive part of the material.
  51933. * This helps controlling the emissive effect without modifying the emissive color.
  51934. */
  51935. emissiveIntensity: number;
  51936. /**
  51937. * Intensity of the environment e.g. how much the environment will light the object
  51938. * either through harmonics for rough material or through the refelction for shiny ones.
  51939. */
  51940. environmentIntensity: number;
  51941. /**
  51942. * This is a special control allowing the reduction of the specular highlights coming from the
  51943. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51944. */
  51945. specularIntensity: number;
  51946. /**
  51947. * Debug Control allowing disabling the bump map on this material.
  51948. */
  51949. disableBumpMap: boolean;
  51950. /**
  51951. * AKA Diffuse Texture in standard nomenclature.
  51952. */
  51953. albedoTexture: BaseTexture;
  51954. /**
  51955. * AKA Occlusion Texture in other nomenclature.
  51956. */
  51957. ambientTexture: BaseTexture;
  51958. /**
  51959. * AKA Occlusion Texture Intensity in other nomenclature.
  51960. */
  51961. ambientTextureStrength: number;
  51962. /**
  51963. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51964. * 1 means it completely occludes it
  51965. * 0 mean it has no impact
  51966. */
  51967. ambientTextureImpactOnAnalyticalLights: number;
  51968. /**
  51969. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51970. */
  51971. opacityTexture: BaseTexture;
  51972. /**
  51973. * Stores the reflection values in a texture.
  51974. */
  51975. reflectionTexture: Nullable<BaseTexture>;
  51976. /**
  51977. * Stores the emissive values in a texture.
  51978. */
  51979. emissiveTexture: BaseTexture;
  51980. /**
  51981. * AKA Specular texture in other nomenclature.
  51982. */
  51983. reflectivityTexture: BaseTexture;
  51984. /**
  51985. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51986. */
  51987. metallicTexture: BaseTexture;
  51988. /**
  51989. * Specifies the metallic scalar of the metallic/roughness workflow.
  51990. * Can also be used to scale the metalness values of the metallic texture.
  51991. */
  51992. metallic: Nullable<number>;
  51993. /**
  51994. * Specifies the roughness scalar of the metallic/roughness workflow.
  51995. * Can also be used to scale the roughness values of the metallic texture.
  51996. */
  51997. roughness: Nullable<number>;
  51998. /**
  51999. * Specifies the an F0 factor to help configuring the material F0.
  52000. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52001. * to 0.5 the previously hard coded value stays the same.
  52002. * Can also be used to scale the F0 values of the metallic texture.
  52003. */
  52004. metallicF0Factor: number;
  52005. /**
  52006. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52007. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52008. * your expectation as it multiplies with the texture data.
  52009. */
  52010. useMetallicF0FactorFromMetallicTexture: boolean;
  52011. /**
  52012. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52013. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52014. */
  52015. microSurfaceTexture: BaseTexture;
  52016. /**
  52017. * Stores surface normal data used to displace a mesh in a texture.
  52018. */
  52019. bumpTexture: BaseTexture;
  52020. /**
  52021. * Stores the pre-calculated light information of a mesh in a texture.
  52022. */
  52023. lightmapTexture: BaseTexture;
  52024. /**
  52025. * Stores the refracted light information in a texture.
  52026. */
  52027. get refractionTexture(): Nullable<BaseTexture>;
  52028. set refractionTexture(value: Nullable<BaseTexture>);
  52029. /**
  52030. * The color of a material in ambient lighting.
  52031. */
  52032. ambientColor: Color3;
  52033. /**
  52034. * AKA Diffuse Color in other nomenclature.
  52035. */
  52036. albedoColor: Color3;
  52037. /**
  52038. * AKA Specular Color in other nomenclature.
  52039. */
  52040. reflectivityColor: Color3;
  52041. /**
  52042. * The color reflected from the material.
  52043. */
  52044. reflectionColor: Color3;
  52045. /**
  52046. * The color emitted from the material.
  52047. */
  52048. emissiveColor: Color3;
  52049. /**
  52050. * AKA Glossiness in other nomenclature.
  52051. */
  52052. microSurface: number;
  52053. /**
  52054. * source material index of refraction (IOR)' / 'destination material IOR.
  52055. */
  52056. get indexOfRefraction(): number;
  52057. set indexOfRefraction(value: number);
  52058. /**
  52059. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52060. */
  52061. get invertRefractionY(): boolean;
  52062. set invertRefractionY(value: boolean);
  52063. /**
  52064. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52065. * Materials half opaque for instance using refraction could benefit from this control.
  52066. */
  52067. get linkRefractionWithTransparency(): boolean;
  52068. set linkRefractionWithTransparency(value: boolean);
  52069. /**
  52070. * If true, the light map contains occlusion information instead of lighting info.
  52071. */
  52072. useLightmapAsShadowmap: boolean;
  52073. /**
  52074. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52075. */
  52076. useAlphaFromAlbedoTexture: boolean;
  52077. /**
  52078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52079. */
  52080. forceAlphaTest: boolean;
  52081. /**
  52082. * Defines the alpha limits in alpha test mode.
  52083. */
  52084. alphaCutOff: number;
  52085. /**
  52086. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52087. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52088. */
  52089. useSpecularOverAlpha: boolean;
  52090. /**
  52091. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52092. */
  52093. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52094. /**
  52095. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52096. */
  52097. useRoughnessFromMetallicTextureAlpha: boolean;
  52098. /**
  52099. * Specifies if the metallic texture contains the roughness information in its green channel.
  52100. */
  52101. useRoughnessFromMetallicTextureGreen: boolean;
  52102. /**
  52103. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52104. */
  52105. useMetallnessFromMetallicTextureBlue: boolean;
  52106. /**
  52107. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52108. */
  52109. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52110. /**
  52111. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52112. */
  52113. useAmbientInGrayScale: boolean;
  52114. /**
  52115. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52116. * The material will try to infer what glossiness each pixel should be.
  52117. */
  52118. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52119. /**
  52120. * BJS is using an harcoded light falloff based on a manually sets up range.
  52121. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52122. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52123. */
  52124. get usePhysicalLightFalloff(): boolean;
  52125. /**
  52126. * BJS is using an harcoded light falloff based on a manually sets up range.
  52127. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52128. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52129. */
  52130. set usePhysicalLightFalloff(value: boolean);
  52131. /**
  52132. * In order to support the falloff compatibility with gltf, a special mode has been added
  52133. * to reproduce the gltf light falloff.
  52134. */
  52135. get useGLTFLightFalloff(): boolean;
  52136. /**
  52137. * In order to support the falloff compatibility with gltf, a special mode has been added
  52138. * to reproduce the gltf light falloff.
  52139. */
  52140. set useGLTFLightFalloff(value: boolean);
  52141. /**
  52142. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52143. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52144. */
  52145. useRadianceOverAlpha: boolean;
  52146. /**
  52147. * Allows using an object space normal map (instead of tangent space).
  52148. */
  52149. useObjectSpaceNormalMap: boolean;
  52150. /**
  52151. * Allows using the bump map in parallax mode.
  52152. */
  52153. useParallax: boolean;
  52154. /**
  52155. * Allows using the bump map in parallax occlusion mode.
  52156. */
  52157. useParallaxOcclusion: boolean;
  52158. /**
  52159. * Controls the scale bias of the parallax mode.
  52160. */
  52161. parallaxScaleBias: number;
  52162. /**
  52163. * If sets to true, disables all the lights affecting the material.
  52164. */
  52165. disableLighting: boolean;
  52166. /**
  52167. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52168. */
  52169. forceIrradianceInFragment: boolean;
  52170. /**
  52171. * Number of Simultaneous lights allowed on the material.
  52172. */
  52173. maxSimultaneousLights: number;
  52174. /**
  52175. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52176. */
  52177. invertNormalMapX: boolean;
  52178. /**
  52179. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52180. */
  52181. invertNormalMapY: boolean;
  52182. /**
  52183. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52184. */
  52185. twoSidedLighting: boolean;
  52186. /**
  52187. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52188. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52189. */
  52190. useAlphaFresnel: boolean;
  52191. /**
  52192. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52193. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52194. */
  52195. useLinearAlphaFresnel: boolean;
  52196. /**
  52197. * Let user defines the brdf lookup texture used for IBL.
  52198. * A default 8bit version is embedded but you could point at :
  52199. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52200. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52201. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52202. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52203. */
  52204. environmentBRDFTexture: Nullable<BaseTexture>;
  52205. /**
  52206. * Force normal to face away from face.
  52207. */
  52208. forceNormalForward: boolean;
  52209. /**
  52210. * Enables specular anti aliasing in the PBR shader.
  52211. * It will both interacts on the Geometry for analytical and IBL lighting.
  52212. * It also prefilter the roughness map based on the bump values.
  52213. */
  52214. enableSpecularAntiAliasing: boolean;
  52215. /**
  52216. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52217. * makes the reflect vector face the model (under horizon).
  52218. */
  52219. useHorizonOcclusion: boolean;
  52220. /**
  52221. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52222. * too much the area relying on ambient texture to define their ambient occlusion.
  52223. */
  52224. useRadianceOcclusion: boolean;
  52225. /**
  52226. * If set to true, no lighting calculations will be applied.
  52227. */
  52228. unlit: boolean;
  52229. /**
  52230. * Gets the image processing configuration used either in this material.
  52231. */
  52232. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52233. /**
  52234. * Sets the Default image processing configuration used either in the this material.
  52235. *
  52236. * If sets to null, the scene one is in use.
  52237. */
  52238. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52239. /**
  52240. * Gets wether the color curves effect is enabled.
  52241. */
  52242. get cameraColorCurvesEnabled(): boolean;
  52243. /**
  52244. * Sets wether the color curves effect is enabled.
  52245. */
  52246. set cameraColorCurvesEnabled(value: boolean);
  52247. /**
  52248. * Gets wether the color grading effect is enabled.
  52249. */
  52250. get cameraColorGradingEnabled(): boolean;
  52251. /**
  52252. * Gets wether the color grading effect is enabled.
  52253. */
  52254. set cameraColorGradingEnabled(value: boolean);
  52255. /**
  52256. * Gets wether tonemapping is enabled or not.
  52257. */
  52258. get cameraToneMappingEnabled(): boolean;
  52259. /**
  52260. * Sets wether tonemapping is enabled or not
  52261. */
  52262. set cameraToneMappingEnabled(value: boolean);
  52263. /**
  52264. * The camera exposure used on this material.
  52265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52266. * This corresponds to a photographic exposure.
  52267. */
  52268. get cameraExposure(): number;
  52269. /**
  52270. * The camera exposure used on this material.
  52271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52272. * This corresponds to a photographic exposure.
  52273. */
  52274. set cameraExposure(value: number);
  52275. /**
  52276. * Gets The camera contrast used on this material.
  52277. */
  52278. get cameraContrast(): number;
  52279. /**
  52280. * Sets The camera contrast used on this material.
  52281. */
  52282. set cameraContrast(value: number);
  52283. /**
  52284. * Gets the Color Grading 2D Lookup Texture.
  52285. */
  52286. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52287. /**
  52288. * Sets the Color Grading 2D Lookup Texture.
  52289. */
  52290. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52291. /**
  52292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52294. * 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;
  52295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52296. */
  52297. get cameraColorCurves(): Nullable<ColorCurves>;
  52298. /**
  52299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52301. * 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;
  52302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52303. */
  52304. set cameraColorCurves(value: Nullable<ColorCurves>);
  52305. /**
  52306. * Instantiates a new PBRMaterial instance.
  52307. *
  52308. * @param name The material name
  52309. * @param scene The scene the material will be use in.
  52310. */
  52311. constructor(name: string, scene: Scene);
  52312. /**
  52313. * Returns the name of this material class.
  52314. */
  52315. getClassName(): string;
  52316. /**
  52317. * Makes a duplicate of the current material.
  52318. * @param name - name to use for the new material.
  52319. */
  52320. clone(name: string): PBRMaterial;
  52321. /**
  52322. * Serializes this PBR Material.
  52323. * @returns - An object with the serialized material.
  52324. */
  52325. serialize(): any;
  52326. /**
  52327. * Parses a PBR Material from a serialized object.
  52328. * @param source - Serialized object.
  52329. * @param scene - BJS scene instance.
  52330. * @param rootUrl - url for the scene object
  52331. * @returns - PBRMaterial
  52332. */
  52333. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52334. }
  52335. }
  52336. declare module BABYLON {
  52337. /**
  52338. * Direct draw surface info
  52339. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52340. */
  52341. export interface DDSInfo {
  52342. /**
  52343. * Width of the texture
  52344. */
  52345. width: number;
  52346. /**
  52347. * Width of the texture
  52348. */
  52349. height: number;
  52350. /**
  52351. * Number of Mipmaps for the texture
  52352. * @see https://en.wikipedia.org/wiki/Mipmap
  52353. */
  52354. mipmapCount: number;
  52355. /**
  52356. * If the textures format is a known fourCC format
  52357. * @see https://www.fourcc.org/
  52358. */
  52359. isFourCC: boolean;
  52360. /**
  52361. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52362. */
  52363. isRGB: boolean;
  52364. /**
  52365. * If the texture is a lumincance format
  52366. */
  52367. isLuminance: boolean;
  52368. /**
  52369. * If this is a cube texture
  52370. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52371. */
  52372. isCube: boolean;
  52373. /**
  52374. * If the texture is a compressed format eg. FOURCC_DXT1
  52375. */
  52376. isCompressed: boolean;
  52377. /**
  52378. * The dxgiFormat of the texture
  52379. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52380. */
  52381. dxgiFormat: number;
  52382. /**
  52383. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52384. */
  52385. textureType: number;
  52386. /**
  52387. * Sphericle polynomial created for the dds texture
  52388. */
  52389. sphericalPolynomial?: SphericalPolynomial;
  52390. }
  52391. /**
  52392. * Class used to provide DDS decompression tools
  52393. */
  52394. export class DDSTools {
  52395. /**
  52396. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52397. */
  52398. static StoreLODInAlphaChannel: boolean;
  52399. /**
  52400. * Gets DDS information from an array buffer
  52401. * @param data defines the array buffer view to read data from
  52402. * @returns the DDS information
  52403. */
  52404. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52405. private static _FloatView;
  52406. private static _Int32View;
  52407. private static _ToHalfFloat;
  52408. private static _FromHalfFloat;
  52409. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52410. private static _GetHalfFloatRGBAArrayBuffer;
  52411. private static _GetFloatRGBAArrayBuffer;
  52412. private static _GetFloatAsUIntRGBAArrayBuffer;
  52413. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52414. private static _GetRGBAArrayBuffer;
  52415. private static _ExtractLongWordOrder;
  52416. private static _GetRGBArrayBuffer;
  52417. private static _GetLuminanceArrayBuffer;
  52418. /**
  52419. * Uploads DDS Levels to a Babylon Texture
  52420. * @hidden
  52421. */
  52422. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52423. }
  52424. interface ThinEngine {
  52425. /**
  52426. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52427. * @param rootUrl defines the url where the file to load is located
  52428. * @param scene defines the current scene
  52429. * @param lodScale defines scale to apply to the mip map selection
  52430. * @param lodOffset defines offset to apply to the mip map selection
  52431. * @param onLoad defines an optional callback raised when the texture is loaded
  52432. * @param onError defines an optional callback raised if there is an issue to load the texture
  52433. * @param format defines the format of the data
  52434. * @param forcedExtension defines the extension to use to pick the right loader
  52435. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52436. * @returns the cube texture as an InternalTexture
  52437. */
  52438. 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;
  52439. }
  52440. }
  52441. declare module BABYLON {
  52442. /**
  52443. * Implementation of the DDS Texture Loader.
  52444. * @hidden
  52445. */
  52446. export class _DDSTextureLoader implements IInternalTextureLoader {
  52447. /**
  52448. * Defines wether the loader supports cascade loading the different faces.
  52449. */
  52450. readonly supportCascades: boolean;
  52451. /**
  52452. * This returns if the loader support the current file information.
  52453. * @param extension defines the file extension of the file being loaded
  52454. * @returns true if the loader can load the specified file
  52455. */
  52456. canLoad(extension: string): boolean;
  52457. /**
  52458. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52459. * @param data contains the texture data
  52460. * @param texture defines the BabylonJS internal texture
  52461. * @param createPolynomials will be true if polynomials have been requested
  52462. * @param onLoad defines the callback to trigger once the texture is ready
  52463. * @param onError defines the callback to trigger in case of error
  52464. */
  52465. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52466. /**
  52467. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52468. * @param data contains the texture data
  52469. * @param texture defines the BabylonJS internal texture
  52470. * @param callback defines the method to call once ready to upload
  52471. */
  52472. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52473. }
  52474. }
  52475. declare module BABYLON {
  52476. /**
  52477. * Implementation of the ENV Texture Loader.
  52478. * @hidden
  52479. */
  52480. export class _ENVTextureLoader implements IInternalTextureLoader {
  52481. /**
  52482. * Defines wether the loader supports cascade loading the different faces.
  52483. */
  52484. readonly supportCascades: boolean;
  52485. /**
  52486. * This returns if the loader support the current file information.
  52487. * @param extension defines the file extension of the file being loaded
  52488. * @returns true if the loader can load the specified file
  52489. */
  52490. canLoad(extension: string): boolean;
  52491. /**
  52492. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52493. * @param data contains the texture data
  52494. * @param texture defines the BabylonJS internal texture
  52495. * @param createPolynomials will be true if polynomials have been requested
  52496. * @param onLoad defines the callback to trigger once the texture is ready
  52497. * @param onError defines the callback to trigger in case of error
  52498. */
  52499. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52500. /**
  52501. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52502. * @param data contains the texture data
  52503. * @param texture defines the BabylonJS internal texture
  52504. * @param callback defines the method to call once ready to upload
  52505. */
  52506. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52507. }
  52508. }
  52509. declare module BABYLON {
  52510. /**
  52511. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52512. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52513. */
  52514. export class KhronosTextureContainer {
  52515. /** contents of the KTX container file */
  52516. data: ArrayBufferView;
  52517. private static HEADER_LEN;
  52518. private static COMPRESSED_2D;
  52519. private static COMPRESSED_3D;
  52520. private static TEX_2D;
  52521. private static TEX_3D;
  52522. /**
  52523. * Gets the openGL type
  52524. */
  52525. glType: number;
  52526. /**
  52527. * Gets the openGL type size
  52528. */
  52529. glTypeSize: number;
  52530. /**
  52531. * Gets the openGL format
  52532. */
  52533. glFormat: number;
  52534. /**
  52535. * Gets the openGL internal format
  52536. */
  52537. glInternalFormat: number;
  52538. /**
  52539. * Gets the base internal format
  52540. */
  52541. glBaseInternalFormat: number;
  52542. /**
  52543. * Gets image width in pixel
  52544. */
  52545. pixelWidth: number;
  52546. /**
  52547. * Gets image height in pixel
  52548. */
  52549. pixelHeight: number;
  52550. /**
  52551. * Gets image depth in pixels
  52552. */
  52553. pixelDepth: number;
  52554. /**
  52555. * Gets the number of array elements
  52556. */
  52557. numberOfArrayElements: number;
  52558. /**
  52559. * Gets the number of faces
  52560. */
  52561. numberOfFaces: number;
  52562. /**
  52563. * Gets the number of mipmap levels
  52564. */
  52565. numberOfMipmapLevels: number;
  52566. /**
  52567. * Gets the bytes of key value data
  52568. */
  52569. bytesOfKeyValueData: number;
  52570. /**
  52571. * Gets the load type
  52572. */
  52573. loadType: number;
  52574. /**
  52575. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52576. */
  52577. isInvalid: boolean;
  52578. /**
  52579. * Creates a new KhronosTextureContainer
  52580. * @param data contents of the KTX container file
  52581. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52582. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52583. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52584. */
  52585. constructor(
  52586. /** contents of the KTX container file */
  52587. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52588. /**
  52589. * Uploads KTX content to a Babylon Texture.
  52590. * It is assumed that the texture has already been created & is currently bound
  52591. * @hidden
  52592. */
  52593. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52594. private _upload2DCompressedLevels;
  52595. /**
  52596. * Checks if the given data starts with a KTX file identifier.
  52597. * @param data the data to check
  52598. * @returns true if the data is a KTX file or false otherwise
  52599. */
  52600. static IsValid(data: ArrayBufferView): boolean;
  52601. }
  52602. }
  52603. declare module BABYLON {
  52604. /**
  52605. * Class for loading KTX2 files
  52606. * !!! Experimental Extension Subject to Changes !!!
  52607. * @hidden
  52608. */
  52609. export class KhronosTextureContainer2 {
  52610. private static _ModulePromise;
  52611. private static _TranscodeFormat;
  52612. constructor(engine: ThinEngine);
  52613. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52614. private _determineTranscodeFormat;
  52615. /**
  52616. * Checks if the given data starts with a KTX2 file identifier.
  52617. * @param data the data to check
  52618. * @returns true if the data is a KTX2 file or false otherwise
  52619. */
  52620. static IsValid(data: ArrayBufferView): boolean;
  52621. }
  52622. }
  52623. declare module BABYLON {
  52624. /**
  52625. * Implementation of the KTX Texture Loader.
  52626. * @hidden
  52627. */
  52628. export class _KTXTextureLoader implements IInternalTextureLoader {
  52629. /**
  52630. * Defines wether the loader supports cascade loading the different faces.
  52631. */
  52632. readonly supportCascades: boolean;
  52633. /**
  52634. * This returns if the loader support the current file information.
  52635. * @param extension defines the file extension of the file being loaded
  52636. * @returns true if the loader can load the specified file
  52637. */
  52638. canLoad(extension: string): boolean;
  52639. /**
  52640. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52641. * @param data contains the texture data
  52642. * @param texture defines the BabylonJS internal texture
  52643. * @param createPolynomials will be true if polynomials have been requested
  52644. * @param onLoad defines the callback to trigger once the texture is ready
  52645. * @param onError defines the callback to trigger in case of error
  52646. */
  52647. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52648. /**
  52649. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52650. * @param data contains the texture data
  52651. * @param texture defines the BabylonJS internal texture
  52652. * @param callback defines the method to call once ready to upload
  52653. */
  52654. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52655. }
  52656. }
  52657. declare module BABYLON {
  52658. /** @hidden */
  52659. export var _forceSceneHelpersToBundle: boolean;
  52660. interface Scene {
  52661. /**
  52662. * Creates a default light for the scene.
  52663. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52664. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52665. */
  52666. createDefaultLight(replace?: boolean): void;
  52667. /**
  52668. * Creates a default camera for the scene.
  52669. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52670. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52671. * @param replace has default false, when true replaces the active camera in the scene
  52672. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52673. */
  52674. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52675. /**
  52676. * Creates a default camera and a default light.
  52677. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52678. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52679. * @param replace has the default false, when true replaces the active camera/light in the scene
  52680. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52681. */
  52682. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52683. /**
  52684. * Creates a new sky box
  52685. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52686. * @param environmentTexture defines the texture to use as environment texture
  52687. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52688. * @param scale defines the overall scale of the skybox
  52689. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52690. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52691. * @returns a new mesh holding the sky box
  52692. */
  52693. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52694. /**
  52695. * Creates a new environment
  52696. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52697. * @param options defines the options you can use to configure the environment
  52698. * @returns the new EnvironmentHelper
  52699. */
  52700. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52701. /**
  52702. * Creates a new VREXperienceHelper
  52703. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52704. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52705. * @returns a new VREXperienceHelper
  52706. */
  52707. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52708. /**
  52709. * Creates a new WebXRDefaultExperience
  52710. * @see http://doc.babylonjs.com/how_to/webxr
  52711. * @param options experience options
  52712. * @returns a promise for a new WebXRDefaultExperience
  52713. */
  52714. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52715. }
  52716. }
  52717. declare module BABYLON {
  52718. /**
  52719. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52720. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52721. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52722. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52723. */
  52724. export class VideoDome extends TransformNode {
  52725. /**
  52726. * Define the video source as a Monoscopic panoramic 360 video.
  52727. */
  52728. static readonly MODE_MONOSCOPIC: number;
  52729. /**
  52730. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52731. */
  52732. static readonly MODE_TOPBOTTOM: number;
  52733. /**
  52734. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52735. */
  52736. static readonly MODE_SIDEBYSIDE: number;
  52737. private _halfDome;
  52738. private _useDirectMapping;
  52739. /**
  52740. * The video texture being displayed on the sphere
  52741. */
  52742. protected _videoTexture: VideoTexture;
  52743. /**
  52744. * Gets the video texture being displayed on the sphere
  52745. */
  52746. get videoTexture(): VideoTexture;
  52747. /**
  52748. * The skybox material
  52749. */
  52750. protected _material: BackgroundMaterial;
  52751. /**
  52752. * The surface used for the skybox
  52753. */
  52754. protected _mesh: Mesh;
  52755. /**
  52756. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52757. */
  52758. private _halfDomeMask;
  52759. /**
  52760. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52761. * Also see the options.resolution property.
  52762. */
  52763. get fovMultiplier(): number;
  52764. set fovMultiplier(value: number);
  52765. private _videoMode;
  52766. /**
  52767. * Gets or set the current video mode for the video. It can be:
  52768. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52769. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52770. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52771. */
  52772. get videoMode(): number;
  52773. set videoMode(value: number);
  52774. /**
  52775. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52776. *
  52777. */
  52778. get halfDome(): boolean;
  52779. /**
  52780. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52781. */
  52782. set halfDome(enabled: boolean);
  52783. /**
  52784. * Oberserver used in Stereoscopic VR Mode.
  52785. */
  52786. private _onBeforeCameraRenderObserver;
  52787. /**
  52788. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52789. * @param name Element's name, child elements will append suffixes for their own names.
  52790. * @param urlsOrVideo defines the url(s) or the video element to use
  52791. * @param options An object containing optional or exposed sub element properties
  52792. */
  52793. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52794. resolution?: number;
  52795. clickToPlay?: boolean;
  52796. autoPlay?: boolean;
  52797. loop?: boolean;
  52798. size?: number;
  52799. poster?: string;
  52800. faceForward?: boolean;
  52801. useDirectMapping?: boolean;
  52802. halfDomeMode?: boolean;
  52803. }, scene: Scene);
  52804. private _changeVideoMode;
  52805. /**
  52806. * Releases resources associated with this node.
  52807. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52808. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52809. */
  52810. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52811. }
  52812. }
  52813. declare module BABYLON {
  52814. /**
  52815. * This class can be used to get instrumentation data from a Babylon engine
  52816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52817. */
  52818. export class EngineInstrumentation implements IDisposable {
  52819. /**
  52820. * Define the instrumented engine.
  52821. */
  52822. engine: Engine;
  52823. private _captureGPUFrameTime;
  52824. private _gpuFrameTimeToken;
  52825. private _gpuFrameTime;
  52826. private _captureShaderCompilationTime;
  52827. private _shaderCompilationTime;
  52828. private _onBeginFrameObserver;
  52829. private _onEndFrameObserver;
  52830. private _onBeforeShaderCompilationObserver;
  52831. private _onAfterShaderCompilationObserver;
  52832. /**
  52833. * Gets the perf counter used for GPU frame time
  52834. */
  52835. get gpuFrameTimeCounter(): PerfCounter;
  52836. /**
  52837. * Gets the GPU frame time capture status
  52838. */
  52839. get captureGPUFrameTime(): boolean;
  52840. /**
  52841. * Enable or disable the GPU frame time capture
  52842. */
  52843. set captureGPUFrameTime(value: boolean);
  52844. /**
  52845. * Gets the perf counter used for shader compilation time
  52846. */
  52847. get shaderCompilationTimeCounter(): PerfCounter;
  52848. /**
  52849. * Gets the shader compilation time capture status
  52850. */
  52851. get captureShaderCompilationTime(): boolean;
  52852. /**
  52853. * Enable or disable the shader compilation time capture
  52854. */
  52855. set captureShaderCompilationTime(value: boolean);
  52856. /**
  52857. * Instantiates a new engine instrumentation.
  52858. * This class can be used to get instrumentation data from a Babylon engine
  52859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52860. * @param engine Defines the engine to instrument
  52861. */
  52862. constructor(
  52863. /**
  52864. * Define the instrumented engine.
  52865. */
  52866. engine: Engine);
  52867. /**
  52868. * Dispose and release associated resources.
  52869. */
  52870. dispose(): void;
  52871. }
  52872. }
  52873. declare module BABYLON {
  52874. /**
  52875. * This class can be used to get instrumentation data from a Babylon engine
  52876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52877. */
  52878. export class SceneInstrumentation implements IDisposable {
  52879. /**
  52880. * Defines the scene to instrument
  52881. */
  52882. scene: Scene;
  52883. private _captureActiveMeshesEvaluationTime;
  52884. private _activeMeshesEvaluationTime;
  52885. private _captureRenderTargetsRenderTime;
  52886. private _renderTargetsRenderTime;
  52887. private _captureFrameTime;
  52888. private _frameTime;
  52889. private _captureRenderTime;
  52890. private _renderTime;
  52891. private _captureInterFrameTime;
  52892. private _interFrameTime;
  52893. private _captureParticlesRenderTime;
  52894. private _particlesRenderTime;
  52895. private _captureSpritesRenderTime;
  52896. private _spritesRenderTime;
  52897. private _capturePhysicsTime;
  52898. private _physicsTime;
  52899. private _captureAnimationsTime;
  52900. private _animationsTime;
  52901. private _captureCameraRenderTime;
  52902. private _cameraRenderTime;
  52903. private _onBeforeActiveMeshesEvaluationObserver;
  52904. private _onAfterActiveMeshesEvaluationObserver;
  52905. private _onBeforeRenderTargetsRenderObserver;
  52906. private _onAfterRenderTargetsRenderObserver;
  52907. private _onAfterRenderObserver;
  52908. private _onBeforeDrawPhaseObserver;
  52909. private _onAfterDrawPhaseObserver;
  52910. private _onBeforeAnimationsObserver;
  52911. private _onBeforeParticlesRenderingObserver;
  52912. private _onAfterParticlesRenderingObserver;
  52913. private _onBeforeSpritesRenderingObserver;
  52914. private _onAfterSpritesRenderingObserver;
  52915. private _onBeforePhysicsObserver;
  52916. private _onAfterPhysicsObserver;
  52917. private _onAfterAnimationsObserver;
  52918. private _onBeforeCameraRenderObserver;
  52919. private _onAfterCameraRenderObserver;
  52920. /**
  52921. * Gets the perf counter used for active meshes evaluation time
  52922. */
  52923. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52924. /**
  52925. * Gets the active meshes evaluation time capture status
  52926. */
  52927. get captureActiveMeshesEvaluationTime(): boolean;
  52928. /**
  52929. * Enable or disable the active meshes evaluation time capture
  52930. */
  52931. set captureActiveMeshesEvaluationTime(value: boolean);
  52932. /**
  52933. * Gets the perf counter used for render targets render time
  52934. */
  52935. get renderTargetsRenderTimeCounter(): PerfCounter;
  52936. /**
  52937. * Gets the render targets render time capture status
  52938. */
  52939. get captureRenderTargetsRenderTime(): boolean;
  52940. /**
  52941. * Enable or disable the render targets render time capture
  52942. */
  52943. set captureRenderTargetsRenderTime(value: boolean);
  52944. /**
  52945. * Gets the perf counter used for particles render time
  52946. */
  52947. get particlesRenderTimeCounter(): PerfCounter;
  52948. /**
  52949. * Gets the particles render time capture status
  52950. */
  52951. get captureParticlesRenderTime(): boolean;
  52952. /**
  52953. * Enable or disable the particles render time capture
  52954. */
  52955. set captureParticlesRenderTime(value: boolean);
  52956. /**
  52957. * Gets the perf counter used for sprites render time
  52958. */
  52959. get spritesRenderTimeCounter(): PerfCounter;
  52960. /**
  52961. * Gets the sprites render time capture status
  52962. */
  52963. get captureSpritesRenderTime(): boolean;
  52964. /**
  52965. * Enable or disable the sprites render time capture
  52966. */
  52967. set captureSpritesRenderTime(value: boolean);
  52968. /**
  52969. * Gets the perf counter used for physics time
  52970. */
  52971. get physicsTimeCounter(): PerfCounter;
  52972. /**
  52973. * Gets the physics time capture status
  52974. */
  52975. get capturePhysicsTime(): boolean;
  52976. /**
  52977. * Enable or disable the physics time capture
  52978. */
  52979. set capturePhysicsTime(value: boolean);
  52980. /**
  52981. * Gets the perf counter used for animations time
  52982. */
  52983. get animationsTimeCounter(): PerfCounter;
  52984. /**
  52985. * Gets the animations time capture status
  52986. */
  52987. get captureAnimationsTime(): boolean;
  52988. /**
  52989. * Enable or disable the animations time capture
  52990. */
  52991. set captureAnimationsTime(value: boolean);
  52992. /**
  52993. * Gets the perf counter used for frame time capture
  52994. */
  52995. get frameTimeCounter(): PerfCounter;
  52996. /**
  52997. * Gets the frame time capture status
  52998. */
  52999. get captureFrameTime(): boolean;
  53000. /**
  53001. * Enable or disable the frame time capture
  53002. */
  53003. set captureFrameTime(value: boolean);
  53004. /**
  53005. * Gets the perf counter used for inter-frames time capture
  53006. */
  53007. get interFrameTimeCounter(): PerfCounter;
  53008. /**
  53009. * Gets the inter-frames time capture status
  53010. */
  53011. get captureInterFrameTime(): boolean;
  53012. /**
  53013. * Enable or disable the inter-frames time capture
  53014. */
  53015. set captureInterFrameTime(value: boolean);
  53016. /**
  53017. * Gets the perf counter used for render time capture
  53018. */
  53019. get renderTimeCounter(): PerfCounter;
  53020. /**
  53021. * Gets the render time capture status
  53022. */
  53023. get captureRenderTime(): boolean;
  53024. /**
  53025. * Enable or disable the render time capture
  53026. */
  53027. set captureRenderTime(value: boolean);
  53028. /**
  53029. * Gets the perf counter used for camera render time capture
  53030. */
  53031. get cameraRenderTimeCounter(): PerfCounter;
  53032. /**
  53033. * Gets the camera render time capture status
  53034. */
  53035. get captureCameraRenderTime(): boolean;
  53036. /**
  53037. * Enable or disable the camera render time capture
  53038. */
  53039. set captureCameraRenderTime(value: boolean);
  53040. /**
  53041. * Gets the perf counter used for draw calls
  53042. */
  53043. get drawCallsCounter(): PerfCounter;
  53044. /**
  53045. * Instantiates a new scene instrumentation.
  53046. * This class can be used to get instrumentation data from a Babylon engine
  53047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53048. * @param scene Defines the scene to instrument
  53049. */
  53050. constructor(
  53051. /**
  53052. * Defines the scene to instrument
  53053. */
  53054. scene: Scene);
  53055. /**
  53056. * Dispose and release associated resources.
  53057. */
  53058. dispose(): void;
  53059. }
  53060. }
  53061. declare module BABYLON {
  53062. /** @hidden */
  53063. export var glowMapGenerationPixelShader: {
  53064. name: string;
  53065. shader: string;
  53066. };
  53067. }
  53068. declare module BABYLON {
  53069. /** @hidden */
  53070. export var glowMapGenerationVertexShader: {
  53071. name: string;
  53072. shader: string;
  53073. };
  53074. }
  53075. declare module BABYLON {
  53076. /**
  53077. * Effect layer options. This helps customizing the behaviour
  53078. * of the effect layer.
  53079. */
  53080. export interface IEffectLayerOptions {
  53081. /**
  53082. * Multiplication factor apply to the canvas size to compute the render target size
  53083. * used to generated the objects (the smaller the faster).
  53084. */
  53085. mainTextureRatio: number;
  53086. /**
  53087. * Enforces a fixed size texture to ensure effect stability across devices.
  53088. */
  53089. mainTextureFixedSize?: number;
  53090. /**
  53091. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53092. */
  53093. alphaBlendingMode: number;
  53094. /**
  53095. * The camera attached to the layer.
  53096. */
  53097. camera: Nullable<Camera>;
  53098. /**
  53099. * The rendering group to draw the layer in.
  53100. */
  53101. renderingGroupId: number;
  53102. }
  53103. /**
  53104. * The effect layer Helps adding post process effect blended with the main pass.
  53105. *
  53106. * This can be for instance use to generate glow or higlight effects on the scene.
  53107. *
  53108. * The effect layer class can not be used directly and is intented to inherited from to be
  53109. * customized per effects.
  53110. */
  53111. export abstract class EffectLayer {
  53112. private _vertexBuffers;
  53113. private _indexBuffer;
  53114. private _cachedDefines;
  53115. private _effectLayerMapGenerationEffect;
  53116. private _effectLayerOptions;
  53117. private _mergeEffect;
  53118. protected _scene: Scene;
  53119. protected _engine: Engine;
  53120. protected _maxSize: number;
  53121. protected _mainTextureDesiredSize: ISize;
  53122. protected _mainTexture: RenderTargetTexture;
  53123. protected _shouldRender: boolean;
  53124. protected _postProcesses: PostProcess[];
  53125. protected _textures: BaseTexture[];
  53126. protected _emissiveTextureAndColor: {
  53127. texture: Nullable<BaseTexture>;
  53128. color: Color4;
  53129. };
  53130. /**
  53131. * The name of the layer
  53132. */
  53133. name: string;
  53134. /**
  53135. * The clear color of the texture used to generate the glow map.
  53136. */
  53137. neutralColor: Color4;
  53138. /**
  53139. * Specifies whether the highlight layer is enabled or not.
  53140. */
  53141. isEnabled: boolean;
  53142. /**
  53143. * Gets the camera attached to the layer.
  53144. */
  53145. get camera(): Nullable<Camera>;
  53146. /**
  53147. * Gets the rendering group id the layer should render in.
  53148. */
  53149. get renderingGroupId(): number;
  53150. set renderingGroupId(renderingGroupId: number);
  53151. /**
  53152. * An event triggered when the effect layer has been disposed.
  53153. */
  53154. onDisposeObservable: Observable<EffectLayer>;
  53155. /**
  53156. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53157. */
  53158. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53159. /**
  53160. * An event triggered when the generated texture is being merged in the scene.
  53161. */
  53162. onBeforeComposeObservable: Observable<EffectLayer>;
  53163. /**
  53164. * An event triggered when the mesh is rendered into the effect render target.
  53165. */
  53166. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53167. /**
  53168. * An event triggered after the mesh has been rendered into the effect render target.
  53169. */
  53170. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53171. /**
  53172. * An event triggered when the generated texture has been merged in the scene.
  53173. */
  53174. onAfterComposeObservable: Observable<EffectLayer>;
  53175. /**
  53176. * An event triggered when the efffect layer changes its size.
  53177. */
  53178. onSizeChangedObservable: Observable<EffectLayer>;
  53179. /** @hidden */
  53180. static _SceneComponentInitialization: (scene: Scene) => void;
  53181. /**
  53182. * Instantiates a new effect Layer and references it in the scene.
  53183. * @param name The name of the layer
  53184. * @param scene The scene to use the layer in
  53185. */
  53186. constructor(
  53187. /** The Friendly of the effect in the scene */
  53188. name: string, scene: Scene);
  53189. /**
  53190. * Get the effect name of the layer.
  53191. * @return The effect name
  53192. */
  53193. abstract getEffectName(): string;
  53194. /**
  53195. * Checks for the readiness of the element composing the layer.
  53196. * @param subMesh the mesh to check for
  53197. * @param useInstances specify whether or not to use instances to render the mesh
  53198. * @return true if ready otherwise, false
  53199. */
  53200. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53201. /**
  53202. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53203. * @returns true if the effect requires stencil during the main canvas render pass.
  53204. */
  53205. abstract needStencil(): boolean;
  53206. /**
  53207. * Create the merge effect. This is the shader use to blit the information back
  53208. * to the main canvas at the end of the scene rendering.
  53209. * @returns The effect containing the shader used to merge the effect on the main canvas
  53210. */
  53211. protected abstract _createMergeEffect(): Effect;
  53212. /**
  53213. * Creates the render target textures and post processes used in the effect layer.
  53214. */
  53215. protected abstract _createTextureAndPostProcesses(): void;
  53216. /**
  53217. * Implementation specific of rendering the generating effect on the main canvas.
  53218. * @param effect The effect used to render through
  53219. */
  53220. protected abstract _internalRender(effect: Effect): void;
  53221. /**
  53222. * Sets the required values for both the emissive texture and and the main color.
  53223. */
  53224. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53225. /**
  53226. * Free any resources and references associated to a mesh.
  53227. * Internal use
  53228. * @param mesh The mesh to free.
  53229. */
  53230. abstract _disposeMesh(mesh: Mesh): void;
  53231. /**
  53232. * Serializes this layer (Glow or Highlight for example)
  53233. * @returns a serialized layer object
  53234. */
  53235. abstract serialize?(): any;
  53236. /**
  53237. * Initializes the effect layer with the required options.
  53238. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53239. */
  53240. protected _init(options: Partial<IEffectLayerOptions>): void;
  53241. /**
  53242. * Generates the index buffer of the full screen quad blending to the main canvas.
  53243. */
  53244. private _generateIndexBuffer;
  53245. /**
  53246. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53247. */
  53248. private _generateVertexBuffer;
  53249. /**
  53250. * Sets the main texture desired size which is the closest power of two
  53251. * of the engine canvas size.
  53252. */
  53253. private _setMainTextureSize;
  53254. /**
  53255. * Creates the main texture for the effect layer.
  53256. */
  53257. protected _createMainTexture(): void;
  53258. /**
  53259. * Adds specific effects defines.
  53260. * @param defines The defines to add specifics to.
  53261. */
  53262. protected _addCustomEffectDefines(defines: string[]): void;
  53263. /**
  53264. * Checks for the readiness of the element composing the layer.
  53265. * @param subMesh the mesh to check for
  53266. * @param useInstances specify whether or not to use instances to render the mesh
  53267. * @param emissiveTexture the associated emissive texture used to generate the glow
  53268. * @return true if ready otherwise, false
  53269. */
  53270. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53271. /**
  53272. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53273. */
  53274. render(): void;
  53275. /**
  53276. * Determine if a given mesh will be used in the current effect.
  53277. * @param mesh mesh to test
  53278. * @returns true if the mesh will be used
  53279. */
  53280. hasMesh(mesh: AbstractMesh): boolean;
  53281. /**
  53282. * Returns true if the layer contains information to display, otherwise false.
  53283. * @returns true if the glow layer should be rendered
  53284. */
  53285. shouldRender(): boolean;
  53286. /**
  53287. * Returns true if the mesh should render, otherwise false.
  53288. * @param mesh The mesh to render
  53289. * @returns true if it should render otherwise false
  53290. */
  53291. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53292. /**
  53293. * Returns true if the mesh can be rendered, otherwise false.
  53294. * @param mesh The mesh to render
  53295. * @param material The material used on the mesh
  53296. * @returns true if it can be rendered otherwise false
  53297. */
  53298. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53299. /**
  53300. * Returns true if the mesh should render, otherwise false.
  53301. * @param mesh The mesh to render
  53302. * @returns true if it should render otherwise false
  53303. */
  53304. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53305. /**
  53306. * Renders the submesh passed in parameter to the generation map.
  53307. */
  53308. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53309. /**
  53310. * Defines whether the current material of the mesh should be use to render the effect.
  53311. * @param mesh defines the current mesh to render
  53312. */
  53313. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53314. /**
  53315. * Rebuild the required buffers.
  53316. * @hidden Internal use only.
  53317. */
  53318. _rebuild(): void;
  53319. /**
  53320. * Dispose only the render target textures and post process.
  53321. */
  53322. private _disposeTextureAndPostProcesses;
  53323. /**
  53324. * Dispose the highlight layer and free resources.
  53325. */
  53326. dispose(): void;
  53327. /**
  53328. * Gets the class name of the effect layer
  53329. * @returns the string with the class name of the effect layer
  53330. */
  53331. getClassName(): string;
  53332. /**
  53333. * Creates an effect layer from parsed effect layer data
  53334. * @param parsedEffectLayer defines effect layer data
  53335. * @param scene defines the current scene
  53336. * @param rootUrl defines the root URL containing the effect layer information
  53337. * @returns a parsed effect Layer
  53338. */
  53339. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53340. }
  53341. }
  53342. declare module BABYLON {
  53343. interface AbstractScene {
  53344. /**
  53345. * The list of effect layers (highlights/glow) added to the scene
  53346. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53347. * @see http://doc.babylonjs.com/how_to/glow_layer
  53348. */
  53349. effectLayers: Array<EffectLayer>;
  53350. /**
  53351. * Removes the given effect layer from this scene.
  53352. * @param toRemove defines the effect layer to remove
  53353. * @returns the index of the removed effect layer
  53354. */
  53355. removeEffectLayer(toRemove: EffectLayer): number;
  53356. /**
  53357. * Adds the given effect layer to this scene
  53358. * @param newEffectLayer defines the effect layer to add
  53359. */
  53360. addEffectLayer(newEffectLayer: EffectLayer): void;
  53361. }
  53362. /**
  53363. * Defines the layer scene component responsible to manage any effect layers
  53364. * in a given scene.
  53365. */
  53366. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53367. /**
  53368. * The component name helpfull to identify the component in the list of scene components.
  53369. */
  53370. readonly name: string;
  53371. /**
  53372. * The scene the component belongs to.
  53373. */
  53374. scene: Scene;
  53375. private _engine;
  53376. private _renderEffects;
  53377. private _needStencil;
  53378. private _previousStencilState;
  53379. /**
  53380. * Creates a new instance of the component for the given scene
  53381. * @param scene Defines the scene to register the component in
  53382. */
  53383. constructor(scene: Scene);
  53384. /**
  53385. * Registers the component in a given scene
  53386. */
  53387. register(): void;
  53388. /**
  53389. * Rebuilds the elements related to this component in case of
  53390. * context lost for instance.
  53391. */
  53392. rebuild(): void;
  53393. /**
  53394. * Serializes the component data to the specified json object
  53395. * @param serializationObject The object to serialize to
  53396. */
  53397. serialize(serializationObject: any): void;
  53398. /**
  53399. * Adds all the elements from the container to the scene
  53400. * @param container the container holding the elements
  53401. */
  53402. addFromContainer(container: AbstractScene): void;
  53403. /**
  53404. * Removes all the elements in the container from the scene
  53405. * @param container contains the elements to remove
  53406. * @param dispose if the removed element should be disposed (default: false)
  53407. */
  53408. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53409. /**
  53410. * Disposes the component and the associated ressources.
  53411. */
  53412. dispose(): void;
  53413. private _isReadyForMesh;
  53414. private _renderMainTexture;
  53415. private _setStencil;
  53416. private _setStencilBack;
  53417. private _draw;
  53418. private _drawCamera;
  53419. private _drawRenderingGroup;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /** @hidden */
  53424. export var glowMapMergePixelShader: {
  53425. name: string;
  53426. shader: string;
  53427. };
  53428. }
  53429. declare module BABYLON {
  53430. /** @hidden */
  53431. export var glowMapMergeVertexShader: {
  53432. name: string;
  53433. shader: string;
  53434. };
  53435. }
  53436. declare module BABYLON {
  53437. interface AbstractScene {
  53438. /**
  53439. * Return a the first highlight layer of the scene with a given name.
  53440. * @param name The name of the highlight layer to look for.
  53441. * @return The highlight layer if found otherwise null.
  53442. */
  53443. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53444. }
  53445. /**
  53446. * Glow layer options. This helps customizing the behaviour
  53447. * of the glow layer.
  53448. */
  53449. export interface IGlowLayerOptions {
  53450. /**
  53451. * Multiplication factor apply to the canvas size to compute the render target size
  53452. * used to generated the glowing objects (the smaller the faster).
  53453. */
  53454. mainTextureRatio: number;
  53455. /**
  53456. * Enforces a fixed size texture to ensure resize independant blur.
  53457. */
  53458. mainTextureFixedSize?: number;
  53459. /**
  53460. * How big is the kernel of the blur texture.
  53461. */
  53462. blurKernelSize: number;
  53463. /**
  53464. * The camera attached to the layer.
  53465. */
  53466. camera: Nullable<Camera>;
  53467. /**
  53468. * Enable MSAA by chosing the number of samples.
  53469. */
  53470. mainTextureSamples?: number;
  53471. /**
  53472. * The rendering group to draw the layer in.
  53473. */
  53474. renderingGroupId: number;
  53475. }
  53476. /**
  53477. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53478. *
  53479. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53480. *
  53481. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53482. */
  53483. export class GlowLayer extends EffectLayer {
  53484. /**
  53485. * Effect Name of the layer.
  53486. */
  53487. static readonly EffectName: string;
  53488. /**
  53489. * The default blur kernel size used for the glow.
  53490. */
  53491. static DefaultBlurKernelSize: number;
  53492. /**
  53493. * The default texture size ratio used for the glow.
  53494. */
  53495. static DefaultTextureRatio: number;
  53496. /**
  53497. * Sets the kernel size of the blur.
  53498. */
  53499. set blurKernelSize(value: number);
  53500. /**
  53501. * Gets the kernel size of the blur.
  53502. */
  53503. get blurKernelSize(): number;
  53504. /**
  53505. * Sets the glow intensity.
  53506. */
  53507. set intensity(value: number);
  53508. /**
  53509. * Gets the glow intensity.
  53510. */
  53511. get intensity(): number;
  53512. private _options;
  53513. private _intensity;
  53514. private _horizontalBlurPostprocess1;
  53515. private _verticalBlurPostprocess1;
  53516. private _horizontalBlurPostprocess2;
  53517. private _verticalBlurPostprocess2;
  53518. private _blurTexture1;
  53519. private _blurTexture2;
  53520. private _postProcesses1;
  53521. private _postProcesses2;
  53522. private _includedOnlyMeshes;
  53523. private _excludedMeshes;
  53524. private _meshesUsingTheirOwnMaterials;
  53525. /**
  53526. * Callback used to let the user override the color selection on a per mesh basis
  53527. */
  53528. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53529. /**
  53530. * Callback used to let the user override the texture selection on a per mesh basis
  53531. */
  53532. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53533. /**
  53534. * Instantiates a new glow Layer and references it to the scene.
  53535. * @param name The name of the layer
  53536. * @param scene The scene to use the layer in
  53537. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53538. */
  53539. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53540. /**
  53541. * Get the effect name of the layer.
  53542. * @return The effect name
  53543. */
  53544. getEffectName(): string;
  53545. /**
  53546. * Create the merge effect. This is the shader use to blit the information back
  53547. * to the main canvas at the end of the scene rendering.
  53548. */
  53549. protected _createMergeEffect(): Effect;
  53550. /**
  53551. * Creates the render target textures and post processes used in the glow layer.
  53552. */
  53553. protected _createTextureAndPostProcesses(): void;
  53554. /**
  53555. * Checks for the readiness of the element composing the layer.
  53556. * @param subMesh the mesh to check for
  53557. * @param useInstances specify wether or not to use instances to render the mesh
  53558. * @param emissiveTexture the associated emissive texture used to generate the glow
  53559. * @return true if ready otherwise, false
  53560. */
  53561. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53562. /**
  53563. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53564. */
  53565. needStencil(): boolean;
  53566. /**
  53567. * Returns true if the mesh can be rendered, otherwise false.
  53568. * @param mesh The mesh to render
  53569. * @param material The material used on the mesh
  53570. * @returns true if it can be rendered otherwise false
  53571. */
  53572. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53573. /**
  53574. * Implementation specific of rendering the generating effect on the main canvas.
  53575. * @param effect The effect used to render through
  53576. */
  53577. protected _internalRender(effect: Effect): void;
  53578. /**
  53579. * Sets the required values for both the emissive texture and and the main color.
  53580. */
  53581. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53582. /**
  53583. * Returns true if the mesh should render, otherwise false.
  53584. * @param mesh The mesh to render
  53585. * @returns true if it should render otherwise false
  53586. */
  53587. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53588. /**
  53589. * Adds specific effects defines.
  53590. * @param defines The defines to add specifics to.
  53591. */
  53592. protected _addCustomEffectDefines(defines: string[]): void;
  53593. /**
  53594. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53595. * @param mesh The mesh to exclude from the glow layer
  53596. */
  53597. addExcludedMesh(mesh: Mesh): void;
  53598. /**
  53599. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53600. * @param mesh The mesh to remove
  53601. */
  53602. removeExcludedMesh(mesh: Mesh): void;
  53603. /**
  53604. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53605. * @param mesh The mesh to include in the glow layer
  53606. */
  53607. addIncludedOnlyMesh(mesh: Mesh): void;
  53608. /**
  53609. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53610. * @param mesh The mesh to remove
  53611. */
  53612. removeIncludedOnlyMesh(mesh: Mesh): void;
  53613. /**
  53614. * Determine if a given mesh will be used in the glow layer
  53615. * @param mesh The mesh to test
  53616. * @returns true if the mesh will be highlighted by the current glow layer
  53617. */
  53618. hasMesh(mesh: AbstractMesh): boolean;
  53619. /**
  53620. * Defines whether the current material of the mesh should be use to render the effect.
  53621. * @param mesh defines the current mesh to render
  53622. */
  53623. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53624. /**
  53625. * Add a mesh to be rendered through its own material and not with emissive only.
  53626. * @param mesh The mesh for which we need to use its material
  53627. */
  53628. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53629. /**
  53630. * Remove a mesh from being rendered through its own material and not with emissive only.
  53631. * @param mesh The mesh for which we need to not use its material
  53632. */
  53633. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53634. /**
  53635. * Free any resources and references associated to a mesh.
  53636. * Internal use
  53637. * @param mesh The mesh to free.
  53638. * @hidden
  53639. */
  53640. _disposeMesh(mesh: Mesh): void;
  53641. /**
  53642. * Gets the class name of the effect layer
  53643. * @returns the string with the class name of the effect layer
  53644. */
  53645. getClassName(): string;
  53646. /**
  53647. * Serializes this glow layer
  53648. * @returns a serialized glow layer object
  53649. */
  53650. serialize(): any;
  53651. /**
  53652. * Creates a Glow Layer from parsed glow layer data
  53653. * @param parsedGlowLayer defines glow layer data
  53654. * @param scene defines the current scene
  53655. * @param rootUrl defines the root URL containing the glow layer information
  53656. * @returns a parsed Glow Layer
  53657. */
  53658. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53659. }
  53660. }
  53661. declare module BABYLON {
  53662. /** @hidden */
  53663. export var glowBlurPostProcessPixelShader: {
  53664. name: string;
  53665. shader: string;
  53666. };
  53667. }
  53668. declare module BABYLON {
  53669. interface AbstractScene {
  53670. /**
  53671. * Return a the first highlight layer of the scene with a given name.
  53672. * @param name The name of the highlight layer to look for.
  53673. * @return The highlight layer if found otherwise null.
  53674. */
  53675. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53676. }
  53677. /**
  53678. * Highlight layer options. This helps customizing the behaviour
  53679. * of the highlight layer.
  53680. */
  53681. export interface IHighlightLayerOptions {
  53682. /**
  53683. * Multiplication factor apply to the canvas size to compute the render target size
  53684. * used to generated the glowing objects (the smaller the faster).
  53685. */
  53686. mainTextureRatio: number;
  53687. /**
  53688. * Enforces a fixed size texture to ensure resize independant blur.
  53689. */
  53690. mainTextureFixedSize?: number;
  53691. /**
  53692. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53693. * of the picture to blur (the smaller the faster).
  53694. */
  53695. blurTextureSizeRatio: number;
  53696. /**
  53697. * How big in texel of the blur texture is the vertical blur.
  53698. */
  53699. blurVerticalSize: number;
  53700. /**
  53701. * How big in texel of the blur texture is the horizontal blur.
  53702. */
  53703. blurHorizontalSize: number;
  53704. /**
  53705. * Alpha blending mode used to apply the blur. Default is combine.
  53706. */
  53707. alphaBlendingMode: number;
  53708. /**
  53709. * The camera attached to the layer.
  53710. */
  53711. camera: Nullable<Camera>;
  53712. /**
  53713. * Should we display highlight as a solid stroke?
  53714. */
  53715. isStroke?: boolean;
  53716. /**
  53717. * The rendering group to draw the layer in.
  53718. */
  53719. renderingGroupId: number;
  53720. }
  53721. /**
  53722. * The highlight layer Helps adding a glow effect around a mesh.
  53723. *
  53724. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53725. * glowy meshes to your scene.
  53726. *
  53727. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53728. */
  53729. export class HighlightLayer extends EffectLayer {
  53730. name: string;
  53731. /**
  53732. * Effect Name of the highlight layer.
  53733. */
  53734. static readonly EffectName: string;
  53735. /**
  53736. * The neutral color used during the preparation of the glow effect.
  53737. * This is black by default as the blend operation is a blend operation.
  53738. */
  53739. static NeutralColor: Color4;
  53740. /**
  53741. * Stencil value used for glowing meshes.
  53742. */
  53743. static GlowingMeshStencilReference: number;
  53744. /**
  53745. * Stencil value used for the other meshes in the scene.
  53746. */
  53747. static NormalMeshStencilReference: number;
  53748. /**
  53749. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53750. */
  53751. innerGlow: boolean;
  53752. /**
  53753. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53754. */
  53755. outerGlow: boolean;
  53756. /**
  53757. * Specifies the horizontal size of the blur.
  53758. */
  53759. set blurHorizontalSize(value: number);
  53760. /**
  53761. * Specifies the vertical size of the blur.
  53762. */
  53763. set blurVerticalSize(value: number);
  53764. /**
  53765. * Gets the horizontal size of the blur.
  53766. */
  53767. get blurHorizontalSize(): number;
  53768. /**
  53769. * Gets the vertical size of the blur.
  53770. */
  53771. get blurVerticalSize(): number;
  53772. /**
  53773. * An event triggered when the highlight layer is being blurred.
  53774. */
  53775. onBeforeBlurObservable: Observable<HighlightLayer>;
  53776. /**
  53777. * An event triggered when the highlight layer has been blurred.
  53778. */
  53779. onAfterBlurObservable: Observable<HighlightLayer>;
  53780. private _instanceGlowingMeshStencilReference;
  53781. private _options;
  53782. private _downSamplePostprocess;
  53783. private _horizontalBlurPostprocess;
  53784. private _verticalBlurPostprocess;
  53785. private _blurTexture;
  53786. private _meshes;
  53787. private _excludedMeshes;
  53788. /**
  53789. * Instantiates a new highlight Layer and references it to the scene..
  53790. * @param name The name of the layer
  53791. * @param scene The scene to use the layer in
  53792. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53793. */
  53794. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53795. /**
  53796. * Get the effect name of the layer.
  53797. * @return The effect name
  53798. */
  53799. getEffectName(): string;
  53800. /**
  53801. * Create the merge effect. This is the shader use to blit the information back
  53802. * to the main canvas at the end of the scene rendering.
  53803. */
  53804. protected _createMergeEffect(): Effect;
  53805. /**
  53806. * Creates the render target textures and post processes used in the highlight layer.
  53807. */
  53808. protected _createTextureAndPostProcesses(): void;
  53809. /**
  53810. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53811. */
  53812. needStencil(): boolean;
  53813. /**
  53814. * Checks for the readiness of the element composing the layer.
  53815. * @param subMesh the mesh to check for
  53816. * @param useInstances specify wether or not to use instances to render the mesh
  53817. * @param emissiveTexture the associated emissive texture used to generate the glow
  53818. * @return true if ready otherwise, false
  53819. */
  53820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53821. /**
  53822. * Implementation specific of rendering the generating effect on the main canvas.
  53823. * @param effect The effect used to render through
  53824. */
  53825. protected _internalRender(effect: Effect): void;
  53826. /**
  53827. * Returns true if the layer contains information to display, otherwise false.
  53828. */
  53829. shouldRender(): boolean;
  53830. /**
  53831. * Returns true if the mesh should render, otherwise false.
  53832. * @param mesh The mesh to render
  53833. * @returns true if it should render otherwise false
  53834. */
  53835. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53836. /**
  53837. * Sets the required values for both the emissive texture and and the main color.
  53838. */
  53839. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53840. /**
  53841. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53842. * @param mesh The mesh to exclude from the highlight layer
  53843. */
  53844. addExcludedMesh(mesh: Mesh): void;
  53845. /**
  53846. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53847. * @param mesh The mesh to highlight
  53848. */
  53849. removeExcludedMesh(mesh: Mesh): void;
  53850. /**
  53851. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53852. * @param mesh mesh to test
  53853. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53854. */
  53855. hasMesh(mesh: AbstractMesh): boolean;
  53856. /**
  53857. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53858. * @param mesh The mesh to highlight
  53859. * @param color The color of the highlight
  53860. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53861. */
  53862. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53863. /**
  53864. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53865. * @param mesh The mesh to highlight
  53866. */
  53867. removeMesh(mesh: Mesh): void;
  53868. /**
  53869. * Remove all the meshes currently referenced in the highlight layer
  53870. */
  53871. removeAllMeshes(): void;
  53872. /**
  53873. * Force the stencil to the normal expected value for none glowing parts
  53874. */
  53875. private _defaultStencilReference;
  53876. /**
  53877. * Free any resources and references associated to a mesh.
  53878. * Internal use
  53879. * @param mesh The mesh to free.
  53880. * @hidden
  53881. */
  53882. _disposeMesh(mesh: Mesh): void;
  53883. /**
  53884. * Dispose the highlight layer and free resources.
  53885. */
  53886. dispose(): void;
  53887. /**
  53888. * Gets the class name of the effect layer
  53889. * @returns the string with the class name of the effect layer
  53890. */
  53891. getClassName(): string;
  53892. /**
  53893. * Serializes this Highlight layer
  53894. * @returns a serialized Highlight layer object
  53895. */
  53896. serialize(): any;
  53897. /**
  53898. * Creates a Highlight layer from parsed Highlight layer data
  53899. * @param parsedHightlightLayer defines the Highlight layer data
  53900. * @param scene defines the current scene
  53901. * @param rootUrl defines the root URL containing the Highlight layer information
  53902. * @returns a parsed Highlight layer
  53903. */
  53904. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. interface AbstractScene {
  53909. /**
  53910. * The list of layers (background and foreground) of the scene
  53911. */
  53912. layers: Array<Layer>;
  53913. }
  53914. /**
  53915. * Defines the layer scene component responsible to manage any layers
  53916. * in a given scene.
  53917. */
  53918. export class LayerSceneComponent implements ISceneComponent {
  53919. /**
  53920. * The component name helpfull to identify the component in the list of scene components.
  53921. */
  53922. readonly name: string;
  53923. /**
  53924. * The scene the component belongs to.
  53925. */
  53926. scene: Scene;
  53927. private _engine;
  53928. /**
  53929. * Creates a new instance of the component for the given scene
  53930. * @param scene Defines the scene to register the component in
  53931. */
  53932. constructor(scene: Scene);
  53933. /**
  53934. * Registers the component in a given scene
  53935. */
  53936. register(): void;
  53937. /**
  53938. * Rebuilds the elements related to this component in case of
  53939. * context lost for instance.
  53940. */
  53941. rebuild(): void;
  53942. /**
  53943. * Disposes the component and the associated ressources.
  53944. */
  53945. dispose(): void;
  53946. private _draw;
  53947. private _drawCameraPredicate;
  53948. private _drawCameraBackground;
  53949. private _drawCameraForeground;
  53950. private _drawRenderTargetPredicate;
  53951. private _drawRenderTargetBackground;
  53952. private _drawRenderTargetForeground;
  53953. /**
  53954. * Adds all the elements from the container to the scene
  53955. * @param container the container holding the elements
  53956. */
  53957. addFromContainer(container: AbstractScene): void;
  53958. /**
  53959. * Removes all the elements in the container from the scene
  53960. * @param container contains the elements to remove
  53961. * @param dispose if the removed element should be disposed (default: false)
  53962. */
  53963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53964. }
  53965. }
  53966. declare module BABYLON {
  53967. /** @hidden */
  53968. export var layerPixelShader: {
  53969. name: string;
  53970. shader: string;
  53971. };
  53972. }
  53973. declare module BABYLON {
  53974. /** @hidden */
  53975. export var layerVertexShader: {
  53976. name: string;
  53977. shader: string;
  53978. };
  53979. }
  53980. declare module BABYLON {
  53981. /**
  53982. * This represents a full screen 2d layer.
  53983. * This can be useful to display a picture in the background of your scene for instance.
  53984. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53985. */
  53986. export class Layer {
  53987. /**
  53988. * Define the name of the layer.
  53989. */
  53990. name: string;
  53991. /**
  53992. * Define the texture the layer should display.
  53993. */
  53994. texture: Nullable<Texture>;
  53995. /**
  53996. * Is the layer in background or foreground.
  53997. */
  53998. isBackground: boolean;
  53999. /**
  54000. * Define the color of the layer (instead of texture).
  54001. */
  54002. color: Color4;
  54003. /**
  54004. * Define the scale of the layer in order to zoom in out of the texture.
  54005. */
  54006. scale: Vector2;
  54007. /**
  54008. * Define an offset for the layer in order to shift the texture.
  54009. */
  54010. offset: Vector2;
  54011. /**
  54012. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54013. */
  54014. alphaBlendingMode: number;
  54015. /**
  54016. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54017. * Alpha test will not mix with the background color in case of transparency.
  54018. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54019. */
  54020. alphaTest: boolean;
  54021. /**
  54022. * Define a mask to restrict the layer to only some of the scene cameras.
  54023. */
  54024. layerMask: number;
  54025. /**
  54026. * Define the list of render target the layer is visible into.
  54027. */
  54028. renderTargetTextures: RenderTargetTexture[];
  54029. /**
  54030. * Define if the layer is only used in renderTarget or if it also
  54031. * renders in the main frame buffer of the canvas.
  54032. */
  54033. renderOnlyInRenderTargetTextures: boolean;
  54034. private _scene;
  54035. private _vertexBuffers;
  54036. private _indexBuffer;
  54037. private _effect;
  54038. private _previousDefines;
  54039. /**
  54040. * An event triggered when the layer is disposed.
  54041. */
  54042. onDisposeObservable: Observable<Layer>;
  54043. private _onDisposeObserver;
  54044. /**
  54045. * Back compatibility with callback before the onDisposeObservable existed.
  54046. * The set callback will be triggered when the layer has been disposed.
  54047. */
  54048. set onDispose(callback: () => void);
  54049. /**
  54050. * An event triggered before rendering the scene
  54051. */
  54052. onBeforeRenderObservable: Observable<Layer>;
  54053. private _onBeforeRenderObserver;
  54054. /**
  54055. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54056. * The set callback will be triggered just before rendering the layer.
  54057. */
  54058. set onBeforeRender(callback: () => void);
  54059. /**
  54060. * An event triggered after rendering the scene
  54061. */
  54062. onAfterRenderObservable: Observable<Layer>;
  54063. private _onAfterRenderObserver;
  54064. /**
  54065. * Back compatibility with callback before the onAfterRenderObservable existed.
  54066. * The set callback will be triggered just after rendering the layer.
  54067. */
  54068. set onAfterRender(callback: () => void);
  54069. /**
  54070. * Instantiates a new layer.
  54071. * This represents a full screen 2d layer.
  54072. * This can be useful to display a picture in the background of your scene for instance.
  54073. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54074. * @param name Define the name of the layer in the scene
  54075. * @param imgUrl Define the url of the texture to display in the layer
  54076. * @param scene Define the scene the layer belongs to
  54077. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54078. * @param color Defines a color for the layer
  54079. */
  54080. constructor(
  54081. /**
  54082. * Define the name of the layer.
  54083. */
  54084. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54085. private _createIndexBuffer;
  54086. /** @hidden */
  54087. _rebuild(): void;
  54088. /**
  54089. * Renders the layer in the scene.
  54090. */
  54091. render(): void;
  54092. /**
  54093. * Disposes and releases the associated ressources.
  54094. */
  54095. dispose(): void;
  54096. }
  54097. }
  54098. declare module BABYLON {
  54099. /** @hidden */
  54100. export var lensFlarePixelShader: {
  54101. name: string;
  54102. shader: string;
  54103. };
  54104. }
  54105. declare module BABYLON {
  54106. /** @hidden */
  54107. export var lensFlareVertexShader: {
  54108. name: string;
  54109. shader: string;
  54110. };
  54111. }
  54112. declare module BABYLON {
  54113. /**
  54114. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54115. * It is usually composed of several `lensFlare`.
  54116. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54117. */
  54118. export class LensFlareSystem {
  54119. /**
  54120. * Define the name of the lens flare system
  54121. */
  54122. name: string;
  54123. /**
  54124. * List of lens flares used in this system.
  54125. */
  54126. lensFlares: LensFlare[];
  54127. /**
  54128. * Define a limit from the border the lens flare can be visible.
  54129. */
  54130. borderLimit: number;
  54131. /**
  54132. * Define a viewport border we do not want to see the lens flare in.
  54133. */
  54134. viewportBorder: number;
  54135. /**
  54136. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54137. */
  54138. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54139. /**
  54140. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54141. */
  54142. layerMask: number;
  54143. /**
  54144. * Define the id of the lens flare system in the scene.
  54145. * (equal to name by default)
  54146. */
  54147. id: string;
  54148. private _scene;
  54149. private _emitter;
  54150. private _vertexBuffers;
  54151. private _indexBuffer;
  54152. private _effect;
  54153. private _positionX;
  54154. private _positionY;
  54155. private _isEnabled;
  54156. /** @hidden */
  54157. static _SceneComponentInitialization: (scene: Scene) => void;
  54158. /**
  54159. * Instantiates a lens flare system.
  54160. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54161. * It is usually composed of several `lensFlare`.
  54162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54163. * @param name Define the name of the lens flare system in the scene
  54164. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54165. * @param scene Define the scene the lens flare system belongs to
  54166. */
  54167. constructor(
  54168. /**
  54169. * Define the name of the lens flare system
  54170. */
  54171. name: string, emitter: any, scene: Scene);
  54172. /**
  54173. * Define if the lens flare system is enabled.
  54174. */
  54175. get isEnabled(): boolean;
  54176. set isEnabled(value: boolean);
  54177. /**
  54178. * Get the scene the effects belongs to.
  54179. * @returns the scene holding the lens flare system
  54180. */
  54181. getScene(): Scene;
  54182. /**
  54183. * Get the emitter of the lens flare system.
  54184. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54185. * @returns the emitter of the lens flare system
  54186. */
  54187. getEmitter(): any;
  54188. /**
  54189. * Set the emitter of the lens flare system.
  54190. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54191. * @param newEmitter Define the new emitter of the system
  54192. */
  54193. setEmitter(newEmitter: any): void;
  54194. /**
  54195. * Get the lens flare system emitter position.
  54196. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54197. * @returns the position
  54198. */
  54199. getEmitterPosition(): Vector3;
  54200. /**
  54201. * @hidden
  54202. */
  54203. computeEffectivePosition(globalViewport: Viewport): boolean;
  54204. /** @hidden */
  54205. _isVisible(): boolean;
  54206. /**
  54207. * @hidden
  54208. */
  54209. render(): boolean;
  54210. /**
  54211. * Dispose and release the lens flare with its associated resources.
  54212. */
  54213. dispose(): void;
  54214. /**
  54215. * Parse a lens flare system from a JSON repressentation
  54216. * @param parsedLensFlareSystem Define the JSON to parse
  54217. * @param scene Define the scene the parsed system should be instantiated in
  54218. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54219. * @returns the parsed system
  54220. */
  54221. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54222. /**
  54223. * Serialize the current Lens Flare System into a JSON representation.
  54224. * @returns the serialized JSON
  54225. */
  54226. serialize(): any;
  54227. }
  54228. }
  54229. declare module BABYLON {
  54230. /**
  54231. * This represents one of the lens effect in a `lensFlareSystem`.
  54232. * It controls one of the indiviual texture used in the effect.
  54233. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54234. */
  54235. export class LensFlare {
  54236. /**
  54237. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54238. */
  54239. size: number;
  54240. /**
  54241. * 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.
  54242. */
  54243. position: number;
  54244. /**
  54245. * Define the lens color.
  54246. */
  54247. color: Color3;
  54248. /**
  54249. * Define the lens texture.
  54250. */
  54251. texture: Nullable<Texture>;
  54252. /**
  54253. * Define the alpha mode to render this particular lens.
  54254. */
  54255. alphaMode: number;
  54256. private _system;
  54257. /**
  54258. * Creates a new Lens Flare.
  54259. * This represents one of the lens effect in a `lensFlareSystem`.
  54260. * It controls one of the indiviual texture used in the effect.
  54261. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54262. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54263. * @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.
  54264. * @param color Define the lens color
  54265. * @param imgUrl Define the lens texture url
  54266. * @param system Define the `lensFlareSystem` this flare is part of
  54267. * @returns The newly created Lens Flare
  54268. */
  54269. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54270. /**
  54271. * Instantiates a new Lens Flare.
  54272. * This represents one of the lens effect in a `lensFlareSystem`.
  54273. * It controls one of the indiviual texture used in the effect.
  54274. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54275. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54276. * @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.
  54277. * @param color Define the lens color
  54278. * @param imgUrl Define the lens texture url
  54279. * @param system Define the `lensFlareSystem` this flare is part of
  54280. */
  54281. constructor(
  54282. /**
  54283. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54284. */
  54285. size: number,
  54286. /**
  54287. * 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.
  54288. */
  54289. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54290. /**
  54291. * Dispose and release the lens flare with its associated resources.
  54292. */
  54293. dispose(): void;
  54294. }
  54295. }
  54296. declare module BABYLON {
  54297. interface AbstractScene {
  54298. /**
  54299. * The list of lens flare system added to the scene
  54300. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54301. */
  54302. lensFlareSystems: Array<LensFlareSystem>;
  54303. /**
  54304. * Removes the given lens flare system from this scene.
  54305. * @param toRemove The lens flare system to remove
  54306. * @returns The index of the removed lens flare system
  54307. */
  54308. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54309. /**
  54310. * Adds the given lens flare system to this scene
  54311. * @param newLensFlareSystem The lens flare system to add
  54312. */
  54313. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54314. /**
  54315. * Gets a lens flare system using its name
  54316. * @param name defines the name to look for
  54317. * @returns the lens flare system or null if not found
  54318. */
  54319. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54320. /**
  54321. * Gets a lens flare system using its id
  54322. * @param id defines the id to look for
  54323. * @returns the lens flare system or null if not found
  54324. */
  54325. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54326. }
  54327. /**
  54328. * Defines the lens flare scene component responsible to manage any lens flares
  54329. * in a given scene.
  54330. */
  54331. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54332. /**
  54333. * The component name helpfull to identify the component in the list of scene components.
  54334. */
  54335. readonly name: string;
  54336. /**
  54337. * The scene the component belongs to.
  54338. */
  54339. scene: Scene;
  54340. /**
  54341. * Creates a new instance of the component for the given scene
  54342. * @param scene Defines the scene to register the component in
  54343. */
  54344. constructor(scene: Scene);
  54345. /**
  54346. * Registers the component in a given scene
  54347. */
  54348. register(): void;
  54349. /**
  54350. * Rebuilds the elements related to this component in case of
  54351. * context lost for instance.
  54352. */
  54353. rebuild(): void;
  54354. /**
  54355. * Adds all the elements from the container to the scene
  54356. * @param container the container holding the elements
  54357. */
  54358. addFromContainer(container: AbstractScene): void;
  54359. /**
  54360. * Removes all the elements in the container from the scene
  54361. * @param container contains the elements to remove
  54362. * @param dispose if the removed element should be disposed (default: false)
  54363. */
  54364. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54365. /**
  54366. * Serializes the component data to the specified json object
  54367. * @param serializationObject The object to serialize to
  54368. */
  54369. serialize(serializationObject: any): void;
  54370. /**
  54371. * Disposes the component and the associated ressources.
  54372. */
  54373. dispose(): void;
  54374. private _draw;
  54375. }
  54376. }
  54377. declare module BABYLON {
  54378. /** @hidden */
  54379. export var depthPixelShader: {
  54380. name: string;
  54381. shader: string;
  54382. };
  54383. }
  54384. declare module BABYLON {
  54385. /** @hidden */
  54386. export var depthVertexShader: {
  54387. name: string;
  54388. shader: string;
  54389. };
  54390. }
  54391. declare module BABYLON {
  54392. /**
  54393. * This represents a depth renderer in Babylon.
  54394. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54395. */
  54396. export class DepthRenderer {
  54397. private _scene;
  54398. private _depthMap;
  54399. private _effect;
  54400. private readonly _storeNonLinearDepth;
  54401. private readonly _clearColor;
  54402. /** Get if the depth renderer is using packed depth or not */
  54403. readonly isPacked: boolean;
  54404. private _cachedDefines;
  54405. private _camera;
  54406. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54407. enabled: boolean;
  54408. /**
  54409. * Specifiess that the depth renderer will only be used within
  54410. * the camera it is created for.
  54411. * This can help forcing its rendering during the camera processing.
  54412. */
  54413. useOnlyInActiveCamera: boolean;
  54414. /** @hidden */
  54415. static _SceneComponentInitialization: (scene: Scene) => void;
  54416. /**
  54417. * Instantiates a depth renderer
  54418. * @param scene The scene the renderer belongs to
  54419. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54420. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54421. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54422. */
  54423. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54424. /**
  54425. * Creates the depth rendering effect and checks if the effect is ready.
  54426. * @param subMesh The submesh to be used to render the depth map of
  54427. * @param useInstances If multiple world instances should be used
  54428. * @returns if the depth renderer is ready to render the depth map
  54429. */
  54430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54431. /**
  54432. * Gets the texture which the depth map will be written to.
  54433. * @returns The depth map texture
  54434. */
  54435. getDepthMap(): RenderTargetTexture;
  54436. /**
  54437. * Disposes of the depth renderer.
  54438. */
  54439. dispose(): void;
  54440. }
  54441. }
  54442. declare module BABYLON {
  54443. /** @hidden */
  54444. export var minmaxReduxPixelShader: {
  54445. name: string;
  54446. shader: string;
  54447. };
  54448. }
  54449. declare module BABYLON {
  54450. /**
  54451. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54452. * and maximum values from all values of the texture.
  54453. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54454. * The source values are read from the red channel of the texture.
  54455. */
  54456. export class MinMaxReducer {
  54457. /**
  54458. * Observable triggered when the computation has been performed
  54459. */
  54460. onAfterReductionPerformed: Observable<{
  54461. min: number;
  54462. max: number;
  54463. }>;
  54464. protected _camera: Camera;
  54465. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54466. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54467. protected _postProcessManager: PostProcessManager;
  54468. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54469. protected _forceFullscreenViewport: boolean;
  54470. /**
  54471. * Creates a min/max reducer
  54472. * @param camera The camera to use for the post processes
  54473. */
  54474. constructor(camera: Camera);
  54475. /**
  54476. * Gets the texture used to read the values from.
  54477. */
  54478. get sourceTexture(): Nullable<RenderTargetTexture>;
  54479. /**
  54480. * Sets the source texture to read the values from.
  54481. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54482. * because in such textures '1' value must not be taken into account to compute the maximum
  54483. * as this value is used to clear the texture.
  54484. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54485. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54486. * @param depthRedux Indicates if the texture is a depth texture or not
  54487. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54488. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54489. */
  54490. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54491. /**
  54492. * Defines the refresh rate of the computation.
  54493. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54494. */
  54495. get refreshRate(): number;
  54496. set refreshRate(value: number);
  54497. protected _activated: boolean;
  54498. /**
  54499. * Gets the activation status of the reducer
  54500. */
  54501. get activated(): boolean;
  54502. /**
  54503. * Activates the reduction computation.
  54504. * When activated, the observers registered in onAfterReductionPerformed are
  54505. * called after the compuation is performed
  54506. */
  54507. activate(): void;
  54508. /**
  54509. * Deactivates the reduction computation.
  54510. */
  54511. deactivate(): void;
  54512. /**
  54513. * Disposes the min/max reducer
  54514. * @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.
  54515. */
  54516. dispose(disposeAll?: boolean): void;
  54517. }
  54518. }
  54519. declare module BABYLON {
  54520. /**
  54521. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54522. */
  54523. export class DepthReducer extends MinMaxReducer {
  54524. private _depthRenderer;
  54525. private _depthRendererId;
  54526. /**
  54527. * Gets the depth renderer used for the computation.
  54528. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54529. */
  54530. get depthRenderer(): Nullable<DepthRenderer>;
  54531. /**
  54532. * Creates a depth reducer
  54533. * @param camera The camera used to render the depth texture
  54534. */
  54535. constructor(camera: Camera);
  54536. /**
  54537. * Sets the depth renderer to use to generate the depth map
  54538. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54539. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54540. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54541. */
  54542. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54543. /** @hidden */
  54544. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54545. /**
  54546. * Activates the reduction computation.
  54547. * When activated, the observers registered in onAfterReductionPerformed are
  54548. * called after the compuation is performed
  54549. */
  54550. activate(): void;
  54551. /**
  54552. * Deactivates the reduction computation.
  54553. */
  54554. deactivate(): void;
  54555. /**
  54556. * Disposes the depth reducer
  54557. * @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.
  54558. */
  54559. dispose(disposeAll?: boolean): void;
  54560. }
  54561. }
  54562. declare module BABYLON {
  54563. /**
  54564. * A CSM implementation allowing casting shadows on large scenes.
  54565. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54566. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54567. */
  54568. export class CascadedShadowGenerator extends ShadowGenerator {
  54569. private static readonly frustumCornersNDCSpace;
  54570. /**
  54571. * Name of the CSM class
  54572. */
  54573. static CLASSNAME: string;
  54574. /**
  54575. * Defines the default number of cascades used by the CSM.
  54576. */
  54577. static readonly DEFAULT_CASCADES_COUNT: number;
  54578. /**
  54579. * Defines the minimum number of cascades used by the CSM.
  54580. */
  54581. static readonly MIN_CASCADES_COUNT: number;
  54582. /**
  54583. * Defines the maximum number of cascades used by the CSM.
  54584. */
  54585. static readonly MAX_CASCADES_COUNT: number;
  54586. protected _validateFilter(filter: number): number;
  54587. /**
  54588. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54589. */
  54590. penumbraDarkness: number;
  54591. private _numCascades;
  54592. /**
  54593. * Gets or set the number of cascades used by the CSM.
  54594. */
  54595. get numCascades(): number;
  54596. set numCascades(value: number);
  54597. /**
  54598. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54599. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54600. */
  54601. stabilizeCascades: boolean;
  54602. private _freezeShadowCastersBoundingInfo;
  54603. private _freezeShadowCastersBoundingInfoObservable;
  54604. /**
  54605. * Enables or disables the shadow casters bounding info computation.
  54606. * If your shadow casters don't move, you can disable this feature.
  54607. * If it is enabled, the bounding box computation is done every frame.
  54608. */
  54609. get freezeShadowCastersBoundingInfo(): boolean;
  54610. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54611. private _scbiMin;
  54612. private _scbiMax;
  54613. protected _computeShadowCastersBoundingInfo(): void;
  54614. protected _shadowCastersBoundingInfo: BoundingInfo;
  54615. /**
  54616. * Gets or sets the shadow casters bounding info.
  54617. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54618. * so that the system won't overwrite the bounds you provide
  54619. */
  54620. get shadowCastersBoundingInfo(): BoundingInfo;
  54621. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54622. protected _breaksAreDirty: boolean;
  54623. protected _minDistance: number;
  54624. protected _maxDistance: number;
  54625. /**
  54626. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54627. *
  54628. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54629. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54630. * @param min minimal distance for the breaks (default to 0.)
  54631. * @param max maximal distance for the breaks (default to 1.)
  54632. */
  54633. setMinMaxDistance(min: number, max: number): void;
  54634. /** Gets the minimal distance used in the cascade break computation */
  54635. get minDistance(): number;
  54636. /** Gets the maximal distance used in the cascade break computation */
  54637. get maxDistance(): number;
  54638. /**
  54639. * Gets the class name of that object
  54640. * @returns "CascadedShadowGenerator"
  54641. */
  54642. getClassName(): string;
  54643. private _cascadeMinExtents;
  54644. private _cascadeMaxExtents;
  54645. /**
  54646. * Gets a cascade minimum extents
  54647. * @param cascadeIndex index of the cascade
  54648. * @returns the minimum cascade extents
  54649. */
  54650. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54651. /**
  54652. * Gets a cascade maximum extents
  54653. * @param cascadeIndex index of the cascade
  54654. * @returns the maximum cascade extents
  54655. */
  54656. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54657. private _cascades;
  54658. private _currentLayer;
  54659. private _viewSpaceFrustumsZ;
  54660. private _viewMatrices;
  54661. private _projectionMatrices;
  54662. private _transformMatrices;
  54663. private _transformMatricesAsArray;
  54664. private _frustumLengths;
  54665. private _lightSizeUVCorrection;
  54666. private _depthCorrection;
  54667. private _frustumCornersWorldSpace;
  54668. private _frustumCenter;
  54669. private _shadowCameraPos;
  54670. private _shadowMaxZ;
  54671. /**
  54672. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54673. * It defaults to camera.maxZ
  54674. */
  54675. get shadowMaxZ(): number;
  54676. /**
  54677. * Sets the shadow max z distance.
  54678. */
  54679. set shadowMaxZ(value: number);
  54680. protected _debug: boolean;
  54681. /**
  54682. * Gets or sets the debug flag.
  54683. * When enabled, the cascades are materialized by different colors on the screen.
  54684. */
  54685. get debug(): boolean;
  54686. set debug(dbg: boolean);
  54687. private _depthClamp;
  54688. /**
  54689. * Gets or sets the depth clamping value.
  54690. *
  54691. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54692. * to account for the shadow casters far away.
  54693. *
  54694. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54695. */
  54696. get depthClamp(): boolean;
  54697. set depthClamp(value: boolean);
  54698. private _cascadeBlendPercentage;
  54699. /**
  54700. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54701. * It defaults to 0.1 (10% blending).
  54702. */
  54703. get cascadeBlendPercentage(): number;
  54704. set cascadeBlendPercentage(value: number);
  54705. private _lambda;
  54706. /**
  54707. * Gets or set the lambda parameter.
  54708. * This parameter is used to split the camera frustum and create the cascades.
  54709. * 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.
  54710. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54711. */
  54712. get lambda(): number;
  54713. set lambda(value: number);
  54714. /**
  54715. * Gets the view matrix corresponding to a given cascade
  54716. * @param cascadeNum cascade to retrieve the view matrix from
  54717. * @returns the cascade view matrix
  54718. */
  54719. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54720. /**
  54721. * Gets the projection matrix corresponding to a given cascade
  54722. * @param cascadeNum cascade to retrieve the projection matrix from
  54723. * @returns the cascade projection matrix
  54724. */
  54725. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54726. /**
  54727. * Gets the transformation matrix corresponding to a given cascade
  54728. * @param cascadeNum cascade to retrieve the transformation matrix from
  54729. * @returns the cascade transformation matrix
  54730. */
  54731. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54732. private _depthRenderer;
  54733. /**
  54734. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54735. *
  54736. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54737. *
  54738. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54739. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54740. * @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
  54741. */
  54742. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54743. private _depthReducer;
  54744. private _autoCalcDepthBounds;
  54745. /**
  54746. * Gets or sets the autoCalcDepthBounds property.
  54747. *
  54748. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54749. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54750. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54751. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54752. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54753. */
  54754. get autoCalcDepthBounds(): boolean;
  54755. set autoCalcDepthBounds(value: boolean);
  54756. /**
  54757. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54758. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54759. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54760. * for setting the refresh rate on the renderer yourself!
  54761. */
  54762. get autoCalcDepthBoundsRefreshRate(): number;
  54763. set autoCalcDepthBoundsRefreshRate(value: number);
  54764. /**
  54765. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54766. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54767. * you change the camera near/far planes!
  54768. */
  54769. splitFrustum(): void;
  54770. private _splitFrustum;
  54771. private _computeMatrices;
  54772. private _computeFrustumInWorldSpace;
  54773. private _computeCascadeFrustum;
  54774. /**
  54775. * Support test.
  54776. */
  54777. static get IsSupported(): boolean;
  54778. /** @hidden */
  54779. static _SceneComponentInitialization: (scene: Scene) => void;
  54780. /**
  54781. * Creates a Cascaded Shadow Generator object.
  54782. * A ShadowGenerator is the required tool to use the shadows.
  54783. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54784. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54785. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54786. * @param light The directional light object generating the shadows.
  54787. * @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.
  54788. */
  54789. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54790. protected _initializeGenerator(): void;
  54791. protected _createTargetRenderTexture(): void;
  54792. protected _initializeShadowMap(): void;
  54793. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54794. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54795. /**
  54796. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54797. * @param defines Defines of the material we want to update
  54798. * @param lightIndex Index of the light in the enabled light list of the material
  54799. */
  54800. prepareDefines(defines: any, lightIndex: number): void;
  54801. /**
  54802. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54803. * defined in the generator but impacting the effect).
  54804. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54805. * @param effect The effect we are binfing the information for
  54806. */
  54807. bindShadowLight(lightIndex: string, effect: Effect): void;
  54808. /**
  54809. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54810. * (eq to view projection * shadow projection matrices)
  54811. * @returns The transform matrix used to create the shadow map
  54812. */
  54813. getTransformMatrix(): Matrix;
  54814. /**
  54815. * Disposes the ShadowGenerator.
  54816. * Returns nothing.
  54817. */
  54818. dispose(): void;
  54819. /**
  54820. * Serializes the shadow generator setup to a json object.
  54821. * @returns The serialized JSON object
  54822. */
  54823. serialize(): any;
  54824. /**
  54825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54826. * @param parsedShadowGenerator The JSON object to parse
  54827. * @param scene The scene to create the shadow map for
  54828. * @returns The parsed shadow generator
  54829. */
  54830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54831. }
  54832. }
  54833. declare module BABYLON {
  54834. /**
  54835. * Defines the shadow generator component responsible to manage any shadow generators
  54836. * in a given scene.
  54837. */
  54838. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54839. /**
  54840. * The component name helpfull to identify the component in the list of scene components.
  54841. */
  54842. readonly name: string;
  54843. /**
  54844. * The scene the component belongs to.
  54845. */
  54846. scene: Scene;
  54847. /**
  54848. * Creates a new instance of the component for the given scene
  54849. * @param scene Defines the scene to register the component in
  54850. */
  54851. constructor(scene: Scene);
  54852. /**
  54853. * Registers the component in a given scene
  54854. */
  54855. register(): void;
  54856. /**
  54857. * Rebuilds the elements related to this component in case of
  54858. * context lost for instance.
  54859. */
  54860. rebuild(): void;
  54861. /**
  54862. * Serializes the component data to the specified json object
  54863. * @param serializationObject The object to serialize to
  54864. */
  54865. serialize(serializationObject: any): void;
  54866. /**
  54867. * Adds all the elements from the container to the scene
  54868. * @param container the container holding the elements
  54869. */
  54870. addFromContainer(container: AbstractScene): void;
  54871. /**
  54872. * Removes all the elements in the container from the scene
  54873. * @param container contains the elements to remove
  54874. * @param dispose if the removed element should be disposed (default: false)
  54875. */
  54876. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54877. /**
  54878. * Rebuilds the elements related to this component in case of
  54879. * context lost for instance.
  54880. */
  54881. dispose(): void;
  54882. private _gatherRenderTargets;
  54883. }
  54884. }
  54885. declare module BABYLON {
  54886. /**
  54887. * A point light is a light defined by an unique point in world space.
  54888. * The light is emitted in every direction from this point.
  54889. * A good example of a point light is a standard light bulb.
  54890. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54891. */
  54892. export class PointLight extends ShadowLight {
  54893. private _shadowAngle;
  54894. /**
  54895. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54896. * This specifies what angle the shadow will use to be created.
  54897. *
  54898. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54899. */
  54900. get shadowAngle(): number;
  54901. /**
  54902. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54903. * This specifies what angle the shadow will use to be created.
  54904. *
  54905. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54906. */
  54907. set shadowAngle(value: number);
  54908. /**
  54909. * Gets the direction if it has been set.
  54910. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54911. */
  54912. get direction(): Vector3;
  54913. /**
  54914. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54915. */
  54916. set direction(value: Vector3);
  54917. /**
  54918. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54919. * A PointLight emits the light in every direction.
  54920. * It can cast shadows.
  54921. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54922. * ```javascript
  54923. * var pointLight = new PointLight("pl", camera.position, scene);
  54924. * ```
  54925. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54926. * @param name The light friendly name
  54927. * @param position The position of the point light in the scene
  54928. * @param scene The scene the lights belongs to
  54929. */
  54930. constructor(name: string, position: Vector3, scene: Scene);
  54931. /**
  54932. * Returns the string "PointLight"
  54933. * @returns the class name
  54934. */
  54935. getClassName(): string;
  54936. /**
  54937. * Returns the integer 0.
  54938. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54939. */
  54940. getTypeID(): number;
  54941. /**
  54942. * Specifies wether or not the shadowmap should be a cube texture.
  54943. * @returns true if the shadowmap needs to be a cube texture.
  54944. */
  54945. needCube(): boolean;
  54946. /**
  54947. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54948. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54949. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54950. */
  54951. getShadowDirection(faceIndex?: number): Vector3;
  54952. /**
  54953. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54954. * - fov = PI / 2
  54955. * - aspect ratio : 1.0
  54956. * - z-near and far equal to the active camera minZ and maxZ.
  54957. * Returns the PointLight.
  54958. */
  54959. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54960. protected _buildUniformLayout(): void;
  54961. /**
  54962. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54963. * @param effect The effect to update
  54964. * @param lightIndex The index of the light in the effect to update
  54965. * @returns The point light
  54966. */
  54967. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54968. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54969. /**
  54970. * Prepares the list of defines specific to the light type.
  54971. * @param defines the list of defines
  54972. * @param lightIndex defines the index of the light for the effect
  54973. */
  54974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54975. }
  54976. }
  54977. declare module BABYLON {
  54978. /**
  54979. * Header information of HDR texture files.
  54980. */
  54981. export interface HDRInfo {
  54982. /**
  54983. * The height of the texture in pixels.
  54984. */
  54985. height: number;
  54986. /**
  54987. * The width of the texture in pixels.
  54988. */
  54989. width: number;
  54990. /**
  54991. * The index of the beginning of the data in the binary file.
  54992. */
  54993. dataPosition: number;
  54994. }
  54995. /**
  54996. * This groups tools to convert HDR texture to native colors array.
  54997. */
  54998. export class HDRTools {
  54999. private static Ldexp;
  55000. private static Rgbe2float;
  55001. private static readStringLine;
  55002. /**
  55003. * Reads header information from an RGBE texture stored in a native array.
  55004. * More information on this format are available here:
  55005. * https://en.wikipedia.org/wiki/RGBE_image_format
  55006. *
  55007. * @param uint8array The binary file stored in native array.
  55008. * @return The header information.
  55009. */
  55010. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55011. /**
  55012. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55013. * This RGBE texture needs to store the information as a panorama.
  55014. *
  55015. * More information on this format are available here:
  55016. * https://en.wikipedia.org/wiki/RGBE_image_format
  55017. *
  55018. * @param buffer The binary file stored in an array buffer.
  55019. * @param size The expected size of the extracted cubemap.
  55020. * @return The Cube Map information.
  55021. */
  55022. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55023. /**
  55024. * Returns the pixels data extracted from an RGBE texture.
  55025. * This pixels will be stored left to right up to down in the R G B order in one array.
  55026. *
  55027. * More information on this format are available here:
  55028. * https://en.wikipedia.org/wiki/RGBE_image_format
  55029. *
  55030. * @param uint8array The binary file stored in an array buffer.
  55031. * @param hdrInfo The header information of the file.
  55032. * @return The pixels data in RGB right to left up to down order.
  55033. */
  55034. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55035. private static RGBE_ReadPixels_RLE;
  55036. }
  55037. }
  55038. declare module BABYLON {
  55039. /**
  55040. * This represents a texture coming from an HDR input.
  55041. *
  55042. * The only supported format is currently panorama picture stored in RGBE format.
  55043. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55044. */
  55045. export class HDRCubeTexture extends BaseTexture {
  55046. private static _facesMapping;
  55047. private _generateHarmonics;
  55048. private _noMipmap;
  55049. private _textureMatrix;
  55050. private _size;
  55051. private _onLoad;
  55052. private _onError;
  55053. /**
  55054. * The texture URL.
  55055. */
  55056. url: string;
  55057. /**
  55058. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55059. */
  55060. coordinatesMode: number;
  55061. protected _isBlocking: boolean;
  55062. /**
  55063. * Sets wether or not the texture is blocking during loading.
  55064. */
  55065. set isBlocking(value: boolean);
  55066. /**
  55067. * Gets wether or not the texture is blocking during loading.
  55068. */
  55069. get isBlocking(): boolean;
  55070. protected _rotationY: number;
  55071. /**
  55072. * Sets texture matrix rotation angle around Y axis in radians.
  55073. */
  55074. set rotationY(value: number);
  55075. /**
  55076. * Gets texture matrix rotation angle around Y axis radians.
  55077. */
  55078. get rotationY(): number;
  55079. /**
  55080. * Gets or sets the center of the bounding box associated with the cube texture
  55081. * It must define where the camera used to render the texture was set
  55082. */
  55083. boundingBoxPosition: Vector3;
  55084. private _boundingBoxSize;
  55085. /**
  55086. * Gets or sets the size of the bounding box associated with the cube texture
  55087. * When defined, the cubemap will switch to local mode
  55088. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55089. * @example https://www.babylonjs-playground.com/#RNASML
  55090. */
  55091. set boundingBoxSize(value: Vector3);
  55092. get boundingBoxSize(): Vector3;
  55093. /**
  55094. * Instantiates an HDRTexture from the following parameters.
  55095. *
  55096. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55097. * @param scene The scene the texture will be used in
  55098. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55099. * @param noMipmap Forces to not generate the mipmap if true
  55100. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55101. * @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)
  55102. * @param reserved Reserved flag for internal use.
  55103. */
  55104. 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>);
  55105. /**
  55106. * Get the current class name of the texture useful for serialization or dynamic coding.
  55107. * @returns "HDRCubeTexture"
  55108. */
  55109. getClassName(): string;
  55110. /**
  55111. * Occurs when the file is raw .hdr file.
  55112. */
  55113. private loadTexture;
  55114. clone(): HDRCubeTexture;
  55115. delayLoad(): void;
  55116. /**
  55117. * Get the texture reflection matrix used to rotate/transform the reflection.
  55118. * @returns the reflection matrix
  55119. */
  55120. getReflectionTextureMatrix(): Matrix;
  55121. /**
  55122. * Set the texture reflection matrix used to rotate/transform the reflection.
  55123. * @param value Define the reflection matrix to set
  55124. */
  55125. setReflectionTextureMatrix(value: Matrix): void;
  55126. /**
  55127. * Parses a JSON representation of an HDR Texture in order to create the texture
  55128. * @param parsedTexture Define the JSON representation
  55129. * @param scene Define the scene the texture should be created in
  55130. * @param rootUrl Define the root url in case we need to load relative dependencies
  55131. * @returns the newly created texture after parsing
  55132. */
  55133. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55134. serialize(): any;
  55135. }
  55136. }
  55137. declare module BABYLON {
  55138. /**
  55139. * Class used to control physics engine
  55140. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55141. */
  55142. export class PhysicsEngine implements IPhysicsEngine {
  55143. private _physicsPlugin;
  55144. /**
  55145. * Global value used to control the smallest number supported by the simulation
  55146. */
  55147. static Epsilon: number;
  55148. private _impostors;
  55149. private _joints;
  55150. private _subTimeStep;
  55151. /**
  55152. * Gets the gravity vector used by the simulation
  55153. */
  55154. gravity: Vector3;
  55155. /**
  55156. * Factory used to create the default physics plugin.
  55157. * @returns The default physics plugin
  55158. */
  55159. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55160. /**
  55161. * Creates a new Physics Engine
  55162. * @param gravity defines the gravity vector used by the simulation
  55163. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55164. */
  55165. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55166. /**
  55167. * Sets the gravity vector used by the simulation
  55168. * @param gravity defines the gravity vector to use
  55169. */
  55170. setGravity(gravity: Vector3): void;
  55171. /**
  55172. * Set the time step of the physics engine.
  55173. * Default is 1/60.
  55174. * To slow it down, enter 1/600 for example.
  55175. * To speed it up, 1/30
  55176. * @param newTimeStep defines the new timestep to apply to this world.
  55177. */
  55178. setTimeStep(newTimeStep?: number): void;
  55179. /**
  55180. * Get the time step of the physics engine.
  55181. * @returns the current time step
  55182. */
  55183. getTimeStep(): number;
  55184. /**
  55185. * Set the sub time step of the physics engine.
  55186. * Default is 0 meaning there is no sub steps
  55187. * To increase physics resolution precision, set a small value (like 1 ms)
  55188. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55189. */
  55190. setSubTimeStep(subTimeStep?: number): void;
  55191. /**
  55192. * Get the sub time step of the physics engine.
  55193. * @returns the current sub time step
  55194. */
  55195. getSubTimeStep(): number;
  55196. /**
  55197. * Release all resources
  55198. */
  55199. dispose(): void;
  55200. /**
  55201. * Gets the name of the current physics plugin
  55202. * @returns the name of the plugin
  55203. */
  55204. getPhysicsPluginName(): string;
  55205. /**
  55206. * Adding a new impostor for the impostor tracking.
  55207. * This will be done by the impostor itself.
  55208. * @param impostor the impostor to add
  55209. */
  55210. addImpostor(impostor: PhysicsImpostor): void;
  55211. /**
  55212. * Remove an impostor from the engine.
  55213. * This impostor and its mesh will not longer be updated by the physics engine.
  55214. * @param impostor the impostor to remove
  55215. */
  55216. removeImpostor(impostor: PhysicsImpostor): void;
  55217. /**
  55218. * Add a joint to the physics engine
  55219. * @param mainImpostor defines the main impostor to which the joint is added.
  55220. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55221. * @param joint defines the joint that will connect both impostors.
  55222. */
  55223. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55224. /**
  55225. * Removes a joint from the simulation
  55226. * @param mainImpostor defines the impostor used with the joint
  55227. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55228. * @param joint defines the joint to remove
  55229. */
  55230. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55231. /**
  55232. * Called by the scene. No need to call it.
  55233. * @param delta defines the timespam between frames
  55234. */
  55235. _step(delta: number): void;
  55236. /**
  55237. * Gets the current plugin used to run the simulation
  55238. * @returns current plugin
  55239. */
  55240. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55241. /**
  55242. * Gets the list of physic impostors
  55243. * @returns an array of PhysicsImpostor
  55244. */
  55245. getImpostors(): Array<PhysicsImpostor>;
  55246. /**
  55247. * Gets the impostor for a physics enabled object
  55248. * @param object defines the object impersonated by the impostor
  55249. * @returns the PhysicsImpostor or null if not found
  55250. */
  55251. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55252. /**
  55253. * Gets the impostor for a physics body object
  55254. * @param body defines physics body used by the impostor
  55255. * @returns the PhysicsImpostor or null if not found
  55256. */
  55257. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55258. /**
  55259. * Does a raycast in the physics world
  55260. * @param from when should the ray start?
  55261. * @param to when should the ray end?
  55262. * @returns PhysicsRaycastResult
  55263. */
  55264. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55265. }
  55266. }
  55267. declare module BABYLON {
  55268. /** @hidden */
  55269. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55270. private _useDeltaForWorldStep;
  55271. world: any;
  55272. name: string;
  55273. private _physicsMaterials;
  55274. private _fixedTimeStep;
  55275. private _cannonRaycastResult;
  55276. private _raycastResult;
  55277. private _physicsBodysToRemoveAfterStep;
  55278. BJSCANNON: any;
  55279. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55280. setGravity(gravity: Vector3): void;
  55281. setTimeStep(timeStep: number): void;
  55282. getTimeStep(): number;
  55283. executeStep(delta: number): void;
  55284. private _removeMarkedPhysicsBodiesFromWorld;
  55285. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55286. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55287. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55288. private _processChildMeshes;
  55289. removePhysicsBody(impostor: PhysicsImpostor): void;
  55290. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55291. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55292. private _addMaterial;
  55293. private _checkWithEpsilon;
  55294. private _createShape;
  55295. private _createHeightmap;
  55296. private _minus90X;
  55297. private _plus90X;
  55298. private _tmpPosition;
  55299. private _tmpDeltaPosition;
  55300. private _tmpUnityRotation;
  55301. private _updatePhysicsBodyTransformation;
  55302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55303. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55304. isSupported(): boolean;
  55305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55307. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55308. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55310. getBodyMass(impostor: PhysicsImpostor): number;
  55311. getBodyFriction(impostor: PhysicsImpostor): number;
  55312. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55313. getBodyRestitution(impostor: PhysicsImpostor): number;
  55314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55315. sleepBody(impostor: PhysicsImpostor): void;
  55316. wakeUpBody(impostor: PhysicsImpostor): void;
  55317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55318. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55319. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55320. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55321. getRadius(impostor: PhysicsImpostor): number;
  55322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55323. dispose(): void;
  55324. private _extendNamespace;
  55325. /**
  55326. * Does a raycast in the physics world
  55327. * @param from when should the ray start?
  55328. * @param to when should the ray end?
  55329. * @returns PhysicsRaycastResult
  55330. */
  55331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55332. }
  55333. }
  55334. declare module BABYLON {
  55335. /** @hidden */
  55336. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55337. world: any;
  55338. name: string;
  55339. BJSOIMO: any;
  55340. private _raycastResult;
  55341. constructor(iterations?: number, oimoInjection?: any);
  55342. setGravity(gravity: Vector3): void;
  55343. setTimeStep(timeStep: number): void;
  55344. getTimeStep(): number;
  55345. private _tmpImpostorsArray;
  55346. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55347. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55348. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55349. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55350. private _tmpPositionVector;
  55351. removePhysicsBody(impostor: PhysicsImpostor): void;
  55352. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55353. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55354. isSupported(): boolean;
  55355. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55356. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55357. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55361. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55362. getBodyMass(impostor: PhysicsImpostor): number;
  55363. getBodyFriction(impostor: PhysicsImpostor): number;
  55364. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55365. getBodyRestitution(impostor: PhysicsImpostor): number;
  55366. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55367. sleepBody(impostor: PhysicsImpostor): void;
  55368. wakeUpBody(impostor: PhysicsImpostor): void;
  55369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55370. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55372. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55373. getRadius(impostor: PhysicsImpostor): number;
  55374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55375. dispose(): void;
  55376. /**
  55377. * Does a raycast in the physics world
  55378. * @param from when should the ray start?
  55379. * @param to when should the ray end?
  55380. * @returns PhysicsRaycastResult
  55381. */
  55382. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55383. }
  55384. }
  55385. declare module BABYLON {
  55386. /**
  55387. * Class containing static functions to help procedurally build meshes
  55388. */
  55389. export class RibbonBuilder {
  55390. /**
  55391. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55392. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55393. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55394. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55395. * * 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
  55396. * * 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
  55397. * * 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
  55398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55399. * * 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
  55400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55401. * * 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
  55402. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55403. * * 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
  55404. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55406. * @param name defines the name of the mesh
  55407. * @param options defines the options used to create the mesh
  55408. * @param scene defines the hosting scene
  55409. * @returns the ribbon mesh
  55410. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55412. */
  55413. static CreateRibbon(name: string, options: {
  55414. pathArray: Vector3[][];
  55415. closeArray?: boolean;
  55416. closePath?: boolean;
  55417. offset?: number;
  55418. updatable?: boolean;
  55419. sideOrientation?: number;
  55420. frontUVs?: Vector4;
  55421. backUVs?: Vector4;
  55422. instance?: Mesh;
  55423. invertUV?: boolean;
  55424. uvs?: Vector2[];
  55425. colors?: Color4[];
  55426. }, scene?: Nullable<Scene>): Mesh;
  55427. }
  55428. }
  55429. declare module BABYLON {
  55430. /**
  55431. * Class containing static functions to help procedurally build meshes
  55432. */
  55433. export class ShapeBuilder {
  55434. /**
  55435. * 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.
  55436. * * 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.
  55437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55438. * * 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.
  55439. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55440. * * 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
  55441. * * 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
  55442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55444. * * 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
  55445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55447. * @param name defines the name of the mesh
  55448. * @param options defines the options used to create the mesh
  55449. * @param scene defines the hosting scene
  55450. * @returns the extruded shape mesh
  55451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55453. */
  55454. static ExtrudeShape(name: string, options: {
  55455. shape: Vector3[];
  55456. path: Vector3[];
  55457. scale?: number;
  55458. rotation?: number;
  55459. cap?: number;
  55460. updatable?: boolean;
  55461. sideOrientation?: number;
  55462. frontUVs?: Vector4;
  55463. backUVs?: Vector4;
  55464. instance?: Mesh;
  55465. invertUV?: boolean;
  55466. }, scene?: Nullable<Scene>): Mesh;
  55467. /**
  55468. * Creates an custom extruded shape mesh.
  55469. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55470. * * 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.
  55471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55472. * * 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
  55473. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55474. * * 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
  55475. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55476. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55477. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55478. * * 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
  55479. * * 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
  55480. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55482. * * 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
  55483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55485. * @param name defines the name of the mesh
  55486. * @param options defines the options used to create the mesh
  55487. * @param scene defines the hosting scene
  55488. * @returns the custom extruded shape mesh
  55489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55492. */
  55493. static ExtrudeShapeCustom(name: string, options: {
  55494. shape: Vector3[];
  55495. path: Vector3[];
  55496. scaleFunction?: any;
  55497. rotationFunction?: any;
  55498. ribbonCloseArray?: boolean;
  55499. ribbonClosePath?: boolean;
  55500. cap?: number;
  55501. updatable?: boolean;
  55502. sideOrientation?: number;
  55503. frontUVs?: Vector4;
  55504. backUVs?: Vector4;
  55505. instance?: Mesh;
  55506. invertUV?: boolean;
  55507. }, scene?: Nullable<Scene>): Mesh;
  55508. private static _ExtrudeShapeGeneric;
  55509. }
  55510. }
  55511. declare module BABYLON {
  55512. /**
  55513. * AmmoJS Physics plugin
  55514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55515. * @see https://github.com/kripken/ammo.js/
  55516. */
  55517. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55518. private _useDeltaForWorldStep;
  55519. /**
  55520. * Reference to the Ammo library
  55521. */
  55522. bjsAMMO: any;
  55523. /**
  55524. * Created ammoJS world which physics bodies are added to
  55525. */
  55526. world: any;
  55527. /**
  55528. * Name of the plugin
  55529. */
  55530. name: string;
  55531. private _timeStep;
  55532. private _fixedTimeStep;
  55533. private _maxSteps;
  55534. private _tmpQuaternion;
  55535. private _tmpAmmoTransform;
  55536. private _tmpAmmoQuaternion;
  55537. private _tmpAmmoConcreteContactResultCallback;
  55538. private _collisionConfiguration;
  55539. private _dispatcher;
  55540. private _overlappingPairCache;
  55541. private _solver;
  55542. private _softBodySolver;
  55543. private _tmpAmmoVectorA;
  55544. private _tmpAmmoVectorB;
  55545. private _tmpAmmoVectorC;
  55546. private _tmpAmmoVectorD;
  55547. private _tmpContactCallbackResult;
  55548. private _tmpAmmoVectorRCA;
  55549. private _tmpAmmoVectorRCB;
  55550. private _raycastResult;
  55551. private static readonly DISABLE_COLLISION_FLAG;
  55552. private static readonly KINEMATIC_FLAG;
  55553. private static readonly DISABLE_DEACTIVATION_FLAG;
  55554. /**
  55555. * Initializes the ammoJS plugin
  55556. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55557. * @param ammoInjection can be used to inject your own ammo reference
  55558. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55559. */
  55560. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55561. /**
  55562. * Sets the gravity of the physics world (m/(s^2))
  55563. * @param gravity Gravity to set
  55564. */
  55565. setGravity(gravity: Vector3): void;
  55566. /**
  55567. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55568. * @param timeStep timestep to use in seconds
  55569. */
  55570. setTimeStep(timeStep: number): void;
  55571. /**
  55572. * 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)
  55573. * @param fixedTimeStep fixedTimeStep to use in seconds
  55574. */
  55575. setFixedTimeStep(fixedTimeStep: number): void;
  55576. /**
  55577. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55578. * @param maxSteps the maximum number of steps by the physics engine per frame
  55579. */
  55580. setMaxSteps(maxSteps: number): void;
  55581. /**
  55582. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55583. * @returns the current timestep in seconds
  55584. */
  55585. getTimeStep(): number;
  55586. /**
  55587. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55588. */
  55589. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55590. private _isImpostorInContact;
  55591. private _isImpostorPairInContact;
  55592. private _stepSimulation;
  55593. /**
  55594. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55595. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55596. * After the step the babylon meshes are set to the position of the physics imposters
  55597. * @param delta amount of time to step forward
  55598. * @param impostors array of imposters to update before/after the step
  55599. */
  55600. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55601. /**
  55602. * Update babylon mesh to match physics world object
  55603. * @param impostor imposter to match
  55604. */
  55605. private _afterSoftStep;
  55606. /**
  55607. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55608. * @param impostor imposter to match
  55609. */
  55610. private _ropeStep;
  55611. /**
  55612. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55613. * @param impostor imposter to match
  55614. */
  55615. private _softbodyOrClothStep;
  55616. private _tmpVector;
  55617. private _tmpMatrix;
  55618. /**
  55619. * Applies an impulse on the imposter
  55620. * @param impostor imposter to apply impulse to
  55621. * @param force amount of force to be applied to the imposter
  55622. * @param contactPoint the location to apply the impulse on the imposter
  55623. */
  55624. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55625. /**
  55626. * Applies a force on the imposter
  55627. * @param impostor imposter to apply force
  55628. * @param force amount of force to be applied to the imposter
  55629. * @param contactPoint the location to apply the force on the imposter
  55630. */
  55631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55632. /**
  55633. * Creates a physics body using the plugin
  55634. * @param impostor the imposter to create the physics body on
  55635. */
  55636. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55637. /**
  55638. * Removes the physics body from the imposter and disposes of the body's memory
  55639. * @param impostor imposter to remove the physics body from
  55640. */
  55641. removePhysicsBody(impostor: PhysicsImpostor): void;
  55642. /**
  55643. * Generates a joint
  55644. * @param impostorJoint the imposter joint to create the joint with
  55645. */
  55646. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55647. /**
  55648. * Removes a joint
  55649. * @param impostorJoint the imposter joint to remove the joint from
  55650. */
  55651. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55652. private _addMeshVerts;
  55653. /**
  55654. * Initialise the soft body vertices to match its object's (mesh) vertices
  55655. * Softbody vertices (nodes) are in world space and to match this
  55656. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55657. * @param impostor to create the softbody for
  55658. */
  55659. private _softVertexData;
  55660. /**
  55661. * Create an impostor's soft body
  55662. * @param impostor to create the softbody for
  55663. */
  55664. private _createSoftbody;
  55665. /**
  55666. * Create cloth for an impostor
  55667. * @param impostor to create the softbody for
  55668. */
  55669. private _createCloth;
  55670. /**
  55671. * Create rope for an impostor
  55672. * @param impostor to create the softbody for
  55673. */
  55674. private _createRope;
  55675. /**
  55676. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55677. * @param impostor to create the custom physics shape for
  55678. */
  55679. private _createCustom;
  55680. private _addHullVerts;
  55681. private _createShape;
  55682. /**
  55683. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55684. * @param impostor imposter containing the physics body and babylon object
  55685. */
  55686. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55687. /**
  55688. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55689. * @param impostor imposter containing the physics body and babylon object
  55690. * @param newPosition new position
  55691. * @param newRotation new rotation
  55692. */
  55693. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55694. /**
  55695. * If this plugin is supported
  55696. * @returns true if its supported
  55697. */
  55698. isSupported(): boolean;
  55699. /**
  55700. * Sets the linear velocity of the physics body
  55701. * @param impostor imposter to set the velocity on
  55702. * @param velocity velocity to set
  55703. */
  55704. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55705. /**
  55706. * Sets the angular velocity of the physics body
  55707. * @param impostor imposter to set the velocity on
  55708. * @param velocity velocity to set
  55709. */
  55710. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55711. /**
  55712. * gets the linear velocity
  55713. * @param impostor imposter to get linear velocity from
  55714. * @returns linear velocity
  55715. */
  55716. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55717. /**
  55718. * gets the angular velocity
  55719. * @param impostor imposter to get angular velocity from
  55720. * @returns angular velocity
  55721. */
  55722. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55723. /**
  55724. * Sets the mass of physics body
  55725. * @param impostor imposter to set the mass on
  55726. * @param mass mass to set
  55727. */
  55728. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55729. /**
  55730. * Gets the mass of the physics body
  55731. * @param impostor imposter to get the mass from
  55732. * @returns mass
  55733. */
  55734. getBodyMass(impostor: PhysicsImpostor): number;
  55735. /**
  55736. * Gets friction of the impostor
  55737. * @param impostor impostor to get friction from
  55738. * @returns friction value
  55739. */
  55740. getBodyFriction(impostor: PhysicsImpostor): number;
  55741. /**
  55742. * Sets friction of the impostor
  55743. * @param impostor impostor to set friction on
  55744. * @param friction friction value
  55745. */
  55746. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55747. /**
  55748. * Gets restitution of the impostor
  55749. * @param impostor impostor to get restitution from
  55750. * @returns restitution value
  55751. */
  55752. getBodyRestitution(impostor: PhysicsImpostor): number;
  55753. /**
  55754. * Sets resitution of the impostor
  55755. * @param impostor impostor to set resitution on
  55756. * @param restitution resitution value
  55757. */
  55758. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55759. /**
  55760. * Gets pressure inside the impostor
  55761. * @param impostor impostor to get pressure from
  55762. * @returns pressure value
  55763. */
  55764. getBodyPressure(impostor: PhysicsImpostor): number;
  55765. /**
  55766. * Sets pressure inside a soft body impostor
  55767. * Cloth and rope must remain 0 pressure
  55768. * @param impostor impostor to set pressure on
  55769. * @param pressure pressure value
  55770. */
  55771. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55772. /**
  55773. * Gets stiffness of the impostor
  55774. * @param impostor impostor to get stiffness from
  55775. * @returns pressure value
  55776. */
  55777. getBodyStiffness(impostor: PhysicsImpostor): number;
  55778. /**
  55779. * Sets stiffness of the impostor
  55780. * @param impostor impostor to set stiffness on
  55781. * @param stiffness stiffness value from 0 to 1
  55782. */
  55783. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55784. /**
  55785. * Gets velocityIterations of the impostor
  55786. * @param impostor impostor to get velocity iterations from
  55787. * @returns velocityIterations value
  55788. */
  55789. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55790. /**
  55791. * Sets velocityIterations of the impostor
  55792. * @param impostor impostor to set velocity iterations on
  55793. * @param velocityIterations velocityIterations value
  55794. */
  55795. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55796. /**
  55797. * Gets positionIterations of the impostor
  55798. * @param impostor impostor to get position iterations from
  55799. * @returns positionIterations value
  55800. */
  55801. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55802. /**
  55803. * Sets positionIterations of the impostor
  55804. * @param impostor impostor to set position on
  55805. * @param positionIterations positionIterations value
  55806. */
  55807. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55808. /**
  55809. * Append an anchor to a cloth object
  55810. * @param impostor is the cloth impostor to add anchor to
  55811. * @param otherImpostor is the rigid impostor to anchor to
  55812. * @param width ratio across width from 0 to 1
  55813. * @param height ratio up height from 0 to 1
  55814. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55815. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55816. */
  55817. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55818. /**
  55819. * Append an hook to a rope object
  55820. * @param impostor is the rope impostor to add hook to
  55821. * @param otherImpostor is the rigid impostor to hook to
  55822. * @param length ratio along the rope from 0 to 1
  55823. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55824. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55825. */
  55826. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55827. /**
  55828. * Sleeps the physics body and stops it from being active
  55829. * @param impostor impostor to sleep
  55830. */
  55831. sleepBody(impostor: PhysicsImpostor): void;
  55832. /**
  55833. * Activates the physics body
  55834. * @param impostor impostor to activate
  55835. */
  55836. wakeUpBody(impostor: PhysicsImpostor): void;
  55837. /**
  55838. * Updates the distance parameters of the joint
  55839. * @param joint joint to update
  55840. * @param maxDistance maximum distance of the joint
  55841. * @param minDistance minimum distance of the joint
  55842. */
  55843. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55844. /**
  55845. * Sets a motor on the joint
  55846. * @param joint joint to set motor on
  55847. * @param speed speed of the motor
  55848. * @param maxForce maximum force of the motor
  55849. * @param motorIndex index of the motor
  55850. */
  55851. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55852. /**
  55853. * Sets the motors limit
  55854. * @param joint joint to set limit on
  55855. * @param upperLimit upper limit
  55856. * @param lowerLimit lower limit
  55857. */
  55858. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55859. /**
  55860. * Syncs the position and rotation of a mesh with the impostor
  55861. * @param mesh mesh to sync
  55862. * @param impostor impostor to update the mesh with
  55863. */
  55864. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55865. /**
  55866. * Gets the radius of the impostor
  55867. * @param impostor impostor to get radius from
  55868. * @returns the radius
  55869. */
  55870. getRadius(impostor: PhysicsImpostor): number;
  55871. /**
  55872. * Gets the box size of the impostor
  55873. * @param impostor impostor to get box size from
  55874. * @param result the resulting box size
  55875. */
  55876. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55877. /**
  55878. * Disposes of the impostor
  55879. */
  55880. dispose(): void;
  55881. /**
  55882. * Does a raycast in the physics world
  55883. * @param from when should the ray start?
  55884. * @param to when should the ray end?
  55885. * @returns PhysicsRaycastResult
  55886. */
  55887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55888. }
  55889. }
  55890. declare module BABYLON {
  55891. interface AbstractScene {
  55892. /**
  55893. * The list of reflection probes added to the scene
  55894. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55895. */
  55896. reflectionProbes: Array<ReflectionProbe>;
  55897. /**
  55898. * Removes the given reflection probe from this scene.
  55899. * @param toRemove The reflection probe to remove
  55900. * @returns The index of the removed reflection probe
  55901. */
  55902. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55903. /**
  55904. * Adds the given reflection probe to this scene.
  55905. * @param newReflectionProbe The reflection probe to add
  55906. */
  55907. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55908. }
  55909. /**
  55910. * Class used to generate realtime reflection / refraction cube textures
  55911. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55912. */
  55913. export class ReflectionProbe {
  55914. /** defines the name of the probe */
  55915. name: string;
  55916. private _scene;
  55917. private _renderTargetTexture;
  55918. private _projectionMatrix;
  55919. private _viewMatrix;
  55920. private _target;
  55921. private _add;
  55922. private _attachedMesh;
  55923. private _invertYAxis;
  55924. /** Gets or sets probe position (center of the cube map) */
  55925. position: Vector3;
  55926. /**
  55927. * Creates a new reflection probe
  55928. * @param name defines the name of the probe
  55929. * @param size defines the texture resolution (for each face)
  55930. * @param scene defines the hosting scene
  55931. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55932. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55933. */
  55934. constructor(
  55935. /** defines the name of the probe */
  55936. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55937. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55938. get samples(): number;
  55939. set samples(value: number);
  55940. /** Gets or sets the refresh rate to use (on every frame by default) */
  55941. get refreshRate(): number;
  55942. set refreshRate(value: number);
  55943. /**
  55944. * Gets the hosting scene
  55945. * @returns a Scene
  55946. */
  55947. getScene(): Scene;
  55948. /** Gets the internal CubeTexture used to render to */
  55949. get cubeTexture(): RenderTargetTexture;
  55950. /** Gets the list of meshes to render */
  55951. get renderList(): Nullable<AbstractMesh[]>;
  55952. /**
  55953. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55954. * @param mesh defines the mesh to attach to
  55955. */
  55956. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55957. /**
  55958. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55959. * @param renderingGroupId The rendering group id corresponding to its index
  55960. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55961. */
  55962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55963. /**
  55964. * Clean all associated resources
  55965. */
  55966. dispose(): void;
  55967. /**
  55968. * Converts the reflection probe information to a readable string for debug purpose.
  55969. * @param fullDetails Supports for multiple levels of logging within scene loading
  55970. * @returns the human readable reflection probe info
  55971. */
  55972. toString(fullDetails?: boolean): string;
  55973. /**
  55974. * Get the class name of the relfection probe.
  55975. * @returns "ReflectionProbe"
  55976. */
  55977. getClassName(): string;
  55978. /**
  55979. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55980. * @returns The JSON representation of the texture
  55981. */
  55982. serialize(): any;
  55983. /**
  55984. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55985. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55986. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55987. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55988. * @returns The parsed reflection probe if successful
  55989. */
  55990. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55991. }
  55992. }
  55993. declare module BABYLON {
  55994. /** @hidden */
  55995. export var _BabylonLoaderRegistered: boolean;
  55996. /**
  55997. * Helps setting up some configuration for the babylon file loader.
  55998. */
  55999. export class BabylonFileLoaderConfiguration {
  56000. /**
  56001. * The loader does not allow injecting custom physix engine into the plugins.
  56002. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56003. * So you could set this variable to your engine import to make it work.
  56004. */
  56005. static LoaderInjectedPhysicsEngine: any;
  56006. }
  56007. }
  56008. declare module BABYLON {
  56009. /**
  56010. * The Physically based simple base material of BJS.
  56011. *
  56012. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56013. * It is used as the base class for both the specGloss and metalRough conventions.
  56014. */
  56015. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56016. /**
  56017. * Number of Simultaneous lights allowed on the material.
  56018. */
  56019. maxSimultaneousLights: number;
  56020. /**
  56021. * If sets to true, disables all the lights affecting the material.
  56022. */
  56023. disableLighting: boolean;
  56024. /**
  56025. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56026. */
  56027. environmentTexture: BaseTexture;
  56028. /**
  56029. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56030. */
  56031. invertNormalMapX: boolean;
  56032. /**
  56033. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56034. */
  56035. invertNormalMapY: boolean;
  56036. /**
  56037. * Normal map used in the model.
  56038. */
  56039. normalTexture: BaseTexture;
  56040. /**
  56041. * Emissivie color used to self-illuminate the model.
  56042. */
  56043. emissiveColor: Color3;
  56044. /**
  56045. * Emissivie texture used to self-illuminate the model.
  56046. */
  56047. emissiveTexture: BaseTexture;
  56048. /**
  56049. * Occlusion Channel Strenght.
  56050. */
  56051. occlusionStrength: number;
  56052. /**
  56053. * Occlusion Texture of the material (adding extra occlusion effects).
  56054. */
  56055. occlusionTexture: BaseTexture;
  56056. /**
  56057. * Defines the alpha limits in alpha test mode.
  56058. */
  56059. alphaCutOff: number;
  56060. /**
  56061. * Gets the current double sided mode.
  56062. */
  56063. get doubleSided(): boolean;
  56064. /**
  56065. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56066. */
  56067. set doubleSided(value: boolean);
  56068. /**
  56069. * Stores the pre-calculated light information of a mesh in a texture.
  56070. */
  56071. lightmapTexture: BaseTexture;
  56072. /**
  56073. * If true, the light map contains occlusion information instead of lighting info.
  56074. */
  56075. useLightmapAsShadowmap: boolean;
  56076. /**
  56077. * Instantiates a new PBRMaterial instance.
  56078. *
  56079. * @param name The material name
  56080. * @param scene The scene the material will be use in.
  56081. */
  56082. constructor(name: string, scene: Scene);
  56083. getClassName(): string;
  56084. }
  56085. }
  56086. declare module BABYLON {
  56087. /**
  56088. * The PBR material of BJS following the metal roughness convention.
  56089. *
  56090. * This fits to the PBR convention in the GLTF definition:
  56091. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56092. */
  56093. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56094. /**
  56095. * The base color has two different interpretations depending on the value of metalness.
  56096. * When the material is a metal, the base color is the specific measured reflectance value
  56097. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56098. * of the material.
  56099. */
  56100. baseColor: Color3;
  56101. /**
  56102. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56103. * well as opacity information in the alpha channel.
  56104. */
  56105. baseTexture: BaseTexture;
  56106. /**
  56107. * Specifies the metallic scalar value of the material.
  56108. * Can also be used to scale the metalness values of the metallic texture.
  56109. */
  56110. metallic: number;
  56111. /**
  56112. * Specifies the roughness scalar value of the material.
  56113. * Can also be used to scale the roughness values of the metallic texture.
  56114. */
  56115. roughness: number;
  56116. /**
  56117. * Texture containing both the metallic value in the B channel and the
  56118. * roughness value in the G channel to keep better precision.
  56119. */
  56120. metallicRoughnessTexture: BaseTexture;
  56121. /**
  56122. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56123. *
  56124. * @param name The material name
  56125. * @param scene The scene the material will be use in.
  56126. */
  56127. constructor(name: string, scene: Scene);
  56128. /**
  56129. * Return the currrent class name of the material.
  56130. */
  56131. getClassName(): string;
  56132. /**
  56133. * Makes a duplicate of the current material.
  56134. * @param name - name to use for the new material.
  56135. */
  56136. clone(name: string): PBRMetallicRoughnessMaterial;
  56137. /**
  56138. * Serialize the material to a parsable JSON object.
  56139. */
  56140. serialize(): any;
  56141. /**
  56142. * Parses a JSON object correponding to the serialize function.
  56143. */
  56144. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56145. }
  56146. }
  56147. declare module BABYLON {
  56148. /**
  56149. * The PBR material of BJS following the specular glossiness convention.
  56150. *
  56151. * This fits to the PBR convention in the GLTF definition:
  56152. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56153. */
  56154. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56155. /**
  56156. * Specifies the diffuse color of the material.
  56157. */
  56158. diffuseColor: Color3;
  56159. /**
  56160. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56161. * channel.
  56162. */
  56163. diffuseTexture: BaseTexture;
  56164. /**
  56165. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56166. */
  56167. specularColor: Color3;
  56168. /**
  56169. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56170. */
  56171. glossiness: number;
  56172. /**
  56173. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56174. */
  56175. specularGlossinessTexture: BaseTexture;
  56176. /**
  56177. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56178. *
  56179. * @param name The material name
  56180. * @param scene The scene the material will be use in.
  56181. */
  56182. constructor(name: string, scene: Scene);
  56183. /**
  56184. * Return the currrent class name of the material.
  56185. */
  56186. getClassName(): string;
  56187. /**
  56188. * Makes a duplicate of the current material.
  56189. * @param name - name to use for the new material.
  56190. */
  56191. clone(name: string): PBRSpecularGlossinessMaterial;
  56192. /**
  56193. * Serialize the material to a parsable JSON object.
  56194. */
  56195. serialize(): any;
  56196. /**
  56197. * Parses a JSON object correponding to the serialize function.
  56198. */
  56199. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56200. }
  56201. }
  56202. declare module BABYLON {
  56203. /**
  56204. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56205. * It can help converting any input color in a desired output one. This can then be used to create effects
  56206. * from sepia, black and white to sixties or futuristic rendering...
  56207. *
  56208. * The only supported format is currently 3dl.
  56209. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56210. */
  56211. export class ColorGradingTexture extends BaseTexture {
  56212. /**
  56213. * The current texture matrix. (will always be identity in color grading texture)
  56214. */
  56215. private _textureMatrix;
  56216. /**
  56217. * The texture URL.
  56218. */
  56219. url: string;
  56220. /**
  56221. * Empty line regex stored for GC.
  56222. */
  56223. private static _noneEmptyLineRegex;
  56224. private _engine;
  56225. /**
  56226. * Instantiates a ColorGradingTexture from the following parameters.
  56227. *
  56228. * @param url The location of the color gradind data (currently only supporting 3dl)
  56229. * @param scene The scene the texture will be used in
  56230. */
  56231. constructor(url: string, scene: Scene);
  56232. /**
  56233. * Returns the texture matrix used in most of the material.
  56234. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56235. */
  56236. getTextureMatrix(): Matrix;
  56237. /**
  56238. * Occurs when the file being loaded is a .3dl LUT file.
  56239. */
  56240. private load3dlTexture;
  56241. /**
  56242. * Starts the loading process of the texture.
  56243. */
  56244. private loadTexture;
  56245. /**
  56246. * Clones the color gradind texture.
  56247. */
  56248. clone(): ColorGradingTexture;
  56249. /**
  56250. * Called during delayed load for textures.
  56251. */
  56252. delayLoad(): void;
  56253. /**
  56254. * Parses a color grading texture serialized by Babylon.
  56255. * @param parsedTexture The texture information being parsedTexture
  56256. * @param scene The scene to load the texture in
  56257. * @param rootUrl The root url of the data assets to load
  56258. * @return A color gradind texture
  56259. */
  56260. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56261. /**
  56262. * Serializes the LUT texture to json format.
  56263. */
  56264. serialize(): any;
  56265. }
  56266. }
  56267. declare module BABYLON {
  56268. /**
  56269. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56270. */
  56271. export class EquiRectangularCubeTexture extends BaseTexture {
  56272. /** The six faces of the cube. */
  56273. private static _FacesMapping;
  56274. private _noMipmap;
  56275. private _onLoad;
  56276. private _onError;
  56277. /** The size of the cubemap. */
  56278. private _size;
  56279. /** The buffer of the image. */
  56280. private _buffer;
  56281. /** The width of the input image. */
  56282. private _width;
  56283. /** The height of the input image. */
  56284. private _height;
  56285. /** The URL to the image. */
  56286. url: string;
  56287. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56288. coordinatesMode: number;
  56289. /**
  56290. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56291. * @param url The location of the image
  56292. * @param scene The scene the texture will be used in
  56293. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56294. * @param noMipmap Forces to not generate the mipmap if true
  56295. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56296. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56297. * @param onLoad — defines a callback called when texture is loaded
  56298. * @param onError — defines a callback called if there is an error
  56299. */
  56300. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56301. /**
  56302. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56303. */
  56304. private loadImage;
  56305. /**
  56306. * Convert the image buffer into a cubemap and create a CubeTexture.
  56307. */
  56308. private loadTexture;
  56309. /**
  56310. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56311. * @param buffer The ArrayBuffer that should be converted.
  56312. * @returns The buffer as Float32Array.
  56313. */
  56314. private getFloat32ArrayFromArrayBuffer;
  56315. /**
  56316. * Get the current class name of the texture useful for serialization or dynamic coding.
  56317. * @returns "EquiRectangularCubeTexture"
  56318. */
  56319. getClassName(): string;
  56320. /**
  56321. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56322. * @returns A clone of the current EquiRectangularCubeTexture.
  56323. */
  56324. clone(): EquiRectangularCubeTexture;
  56325. }
  56326. }
  56327. declare module BABYLON {
  56328. /**
  56329. * Based on jsTGALoader - Javascript loader for TGA file
  56330. * By Vincent Thibault
  56331. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56332. */
  56333. export class TGATools {
  56334. private static _TYPE_INDEXED;
  56335. private static _TYPE_RGB;
  56336. private static _TYPE_GREY;
  56337. private static _TYPE_RLE_INDEXED;
  56338. private static _TYPE_RLE_RGB;
  56339. private static _TYPE_RLE_GREY;
  56340. private static _ORIGIN_MASK;
  56341. private static _ORIGIN_SHIFT;
  56342. private static _ORIGIN_BL;
  56343. private static _ORIGIN_BR;
  56344. private static _ORIGIN_UL;
  56345. private static _ORIGIN_UR;
  56346. /**
  56347. * Gets the header of a TGA file
  56348. * @param data defines the TGA data
  56349. * @returns the header
  56350. */
  56351. static GetTGAHeader(data: Uint8Array): any;
  56352. /**
  56353. * Uploads TGA content to a Babylon Texture
  56354. * @hidden
  56355. */
  56356. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56357. /** @hidden */
  56358. 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;
  56359. /** @hidden */
  56360. 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;
  56361. /** @hidden */
  56362. 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;
  56363. /** @hidden */
  56364. 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;
  56365. /** @hidden */
  56366. 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;
  56367. /** @hidden */
  56368. 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;
  56369. }
  56370. }
  56371. declare module BABYLON {
  56372. /**
  56373. * Implementation of the TGA Texture Loader.
  56374. * @hidden
  56375. */
  56376. export class _TGATextureLoader implements IInternalTextureLoader {
  56377. /**
  56378. * Defines wether the loader supports cascade loading the different faces.
  56379. */
  56380. readonly supportCascades: boolean;
  56381. /**
  56382. * This returns if the loader support the current file information.
  56383. * @param extension defines the file extension of the file being loaded
  56384. * @returns true if the loader can load the specified file
  56385. */
  56386. canLoad(extension: string): boolean;
  56387. /**
  56388. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56389. * @param data contains the texture data
  56390. * @param texture defines the BabylonJS internal texture
  56391. * @param createPolynomials will be true if polynomials have been requested
  56392. * @param onLoad defines the callback to trigger once the texture is ready
  56393. * @param onError defines the callback to trigger in case of error
  56394. */
  56395. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56396. /**
  56397. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56398. * @param data contains the texture data
  56399. * @param texture defines the BabylonJS internal texture
  56400. * @param callback defines the method to call once ready to upload
  56401. */
  56402. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56403. }
  56404. }
  56405. declare module BABYLON {
  56406. /**
  56407. * Info about the .basis files
  56408. */
  56409. class BasisFileInfo {
  56410. /**
  56411. * If the file has alpha
  56412. */
  56413. hasAlpha: boolean;
  56414. /**
  56415. * Info about each image of the basis file
  56416. */
  56417. images: Array<{
  56418. levels: Array<{
  56419. width: number;
  56420. height: number;
  56421. transcodedPixels: ArrayBufferView;
  56422. }>;
  56423. }>;
  56424. }
  56425. /**
  56426. * Result of transcoding a basis file
  56427. */
  56428. class TranscodeResult {
  56429. /**
  56430. * Info about the .basis file
  56431. */
  56432. fileInfo: BasisFileInfo;
  56433. /**
  56434. * Format to use when loading the file
  56435. */
  56436. format: number;
  56437. }
  56438. /**
  56439. * Configuration options for the Basis transcoder
  56440. */
  56441. export class BasisTranscodeConfiguration {
  56442. /**
  56443. * Supported compression formats used to determine the supported output format of the transcoder
  56444. */
  56445. supportedCompressionFormats?: {
  56446. /**
  56447. * etc1 compression format
  56448. */
  56449. etc1?: boolean;
  56450. /**
  56451. * s3tc compression format
  56452. */
  56453. s3tc?: boolean;
  56454. /**
  56455. * pvrtc compression format
  56456. */
  56457. pvrtc?: boolean;
  56458. /**
  56459. * etc2 compression format
  56460. */
  56461. etc2?: boolean;
  56462. };
  56463. /**
  56464. * If mipmap levels should be loaded for transcoded images (Default: true)
  56465. */
  56466. loadMipmapLevels?: boolean;
  56467. /**
  56468. * Index of a single image to load (Default: all images)
  56469. */
  56470. loadSingleImage?: number;
  56471. }
  56472. /**
  56473. * Used to load .Basis files
  56474. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56475. */
  56476. export class BasisTools {
  56477. private static _IgnoreSupportedFormats;
  56478. /**
  56479. * URL to use when loading the basis transcoder
  56480. */
  56481. static JSModuleURL: string;
  56482. /**
  56483. * URL to use when loading the wasm module for the transcoder
  56484. */
  56485. static WasmModuleURL: string;
  56486. /**
  56487. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56488. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56489. * @returns internal format corresponding to the Basis format
  56490. */
  56491. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56492. private static _WorkerPromise;
  56493. private static _Worker;
  56494. private static _actionId;
  56495. private static _CreateWorkerAsync;
  56496. /**
  56497. * Transcodes a loaded image file to compressed pixel data
  56498. * @param data image data to transcode
  56499. * @param config configuration options for the transcoding
  56500. * @returns a promise resulting in the transcoded image
  56501. */
  56502. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56503. /**
  56504. * Loads a texture from the transcode result
  56505. * @param texture texture load to
  56506. * @param transcodeResult the result of transcoding the basis file to load from
  56507. */
  56508. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56509. }
  56510. }
  56511. declare module BABYLON {
  56512. /**
  56513. * Loader for .basis file format
  56514. */
  56515. export class _BasisTextureLoader implements IInternalTextureLoader {
  56516. /**
  56517. * Defines whether the loader supports cascade loading the different faces.
  56518. */
  56519. readonly supportCascades: boolean;
  56520. /**
  56521. * This returns if the loader support the current file information.
  56522. * @param extension defines the file extension of the file being loaded
  56523. * @returns true if the loader can load the specified file
  56524. */
  56525. canLoad(extension: string): boolean;
  56526. /**
  56527. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56528. * @param data contains the texture data
  56529. * @param texture defines the BabylonJS internal texture
  56530. * @param createPolynomials will be true if polynomials have been requested
  56531. * @param onLoad defines the callback to trigger once the texture is ready
  56532. * @param onError defines the callback to trigger in case of error
  56533. */
  56534. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56535. /**
  56536. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56537. * @param data contains the texture data
  56538. * @param texture defines the BabylonJS internal texture
  56539. * @param callback defines the method to call once ready to upload
  56540. */
  56541. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56542. }
  56543. }
  56544. declare module BABYLON {
  56545. /**
  56546. * 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.
  56547. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56548. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56549. */
  56550. export class CustomProceduralTexture extends ProceduralTexture {
  56551. private _animate;
  56552. private _time;
  56553. private _config;
  56554. private _texturePath;
  56555. /**
  56556. * Instantiates a new Custom Procedural Texture.
  56557. * 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.
  56558. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56559. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56560. * @param name Define the name of the texture
  56561. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56562. * @param size Define the size of the texture to create
  56563. * @param scene Define the scene the texture belongs to
  56564. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56565. * @param generateMipMaps Define if the texture should creates mip maps or not
  56566. */
  56567. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56568. private _loadJson;
  56569. /**
  56570. * Is the texture ready to be used ? (rendered at least once)
  56571. * @returns true if ready, otherwise, false.
  56572. */
  56573. isReady(): boolean;
  56574. /**
  56575. * Render the texture to its associated render target.
  56576. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56577. */
  56578. render(useCameraPostProcess?: boolean): void;
  56579. /**
  56580. * Update the list of dependant textures samplers in the shader.
  56581. */
  56582. updateTextures(): void;
  56583. /**
  56584. * Update the uniform values of the procedural texture in the shader.
  56585. */
  56586. updateShaderUniforms(): void;
  56587. /**
  56588. * Define if the texture animates or not.
  56589. */
  56590. get animate(): boolean;
  56591. set animate(value: boolean);
  56592. }
  56593. }
  56594. declare module BABYLON {
  56595. /** @hidden */
  56596. export var noisePixelShader: {
  56597. name: string;
  56598. shader: string;
  56599. };
  56600. }
  56601. declare module BABYLON {
  56602. /**
  56603. * Class used to generate noise procedural textures
  56604. */
  56605. export class NoiseProceduralTexture extends ProceduralTexture {
  56606. private _time;
  56607. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56608. brightness: number;
  56609. /** Defines the number of octaves to process */
  56610. octaves: number;
  56611. /** Defines the level of persistence (0.8 by default) */
  56612. persistence: number;
  56613. /** Gets or sets animation speed factor (default is 1) */
  56614. animationSpeedFactor: number;
  56615. /**
  56616. * Creates a new NoiseProceduralTexture
  56617. * @param name defines the name fo the texture
  56618. * @param size defines the size of the texture (default is 256)
  56619. * @param scene defines the hosting scene
  56620. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56621. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56622. */
  56623. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56624. private _updateShaderUniforms;
  56625. protected _getDefines(): string;
  56626. /** Generate the current state of the procedural texture */
  56627. render(useCameraPostProcess?: boolean): void;
  56628. /**
  56629. * Serializes this noise procedural texture
  56630. * @returns a serialized noise procedural texture object
  56631. */
  56632. serialize(): any;
  56633. /**
  56634. * Clone the texture.
  56635. * @returns the cloned texture
  56636. */
  56637. clone(): NoiseProceduralTexture;
  56638. /**
  56639. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56640. * @param parsedTexture defines parsed texture data
  56641. * @param scene defines the current scene
  56642. * @param rootUrl defines the root URL containing noise procedural texture information
  56643. * @returns a parsed NoiseProceduralTexture
  56644. */
  56645. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56646. }
  56647. }
  56648. declare module BABYLON {
  56649. /**
  56650. * Raw cube texture where the raw buffers are passed in
  56651. */
  56652. export class RawCubeTexture extends CubeTexture {
  56653. /**
  56654. * Creates a cube texture where the raw buffers are passed in.
  56655. * @param scene defines the scene the texture is attached to
  56656. * @param data defines the array of data to use to create each face
  56657. * @param size defines the size of the textures
  56658. * @param format defines the format of the data
  56659. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56660. * @param generateMipMaps defines if the engine should generate the mip levels
  56661. * @param invertY defines if data must be stored with Y axis inverted
  56662. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56663. * @param compression defines the compression used (null by default)
  56664. */
  56665. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56666. /**
  56667. * Updates the raw cube texture.
  56668. * @param data defines the data to store
  56669. * @param format defines the data format
  56670. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56671. * @param invertY defines if data must be stored with Y axis inverted
  56672. * @param compression defines the compression used (null by default)
  56673. * @param level defines which level of the texture to update
  56674. */
  56675. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56676. /**
  56677. * Updates a raw cube texture with RGBD encoded data.
  56678. * @param data defines the array of data [mipmap][face] to use to create each face
  56679. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56680. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56681. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56682. * @returns a promsie that resolves when the operation is complete
  56683. */
  56684. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56685. /**
  56686. * Clones the raw cube texture.
  56687. * @return a new cube texture
  56688. */
  56689. clone(): CubeTexture;
  56690. /** @hidden */
  56691. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56692. }
  56693. }
  56694. declare module BABYLON {
  56695. /**
  56696. * Class used to store 3D textures containing user data
  56697. */
  56698. export class RawTexture3D extends Texture {
  56699. /** Gets or sets the texture format to use */
  56700. format: number;
  56701. private _engine;
  56702. /**
  56703. * Create a new RawTexture3D
  56704. * @param data defines the data of the texture
  56705. * @param width defines the width of the texture
  56706. * @param height defines the height of the texture
  56707. * @param depth defines the depth of the texture
  56708. * @param format defines the texture format to use
  56709. * @param scene defines the hosting scene
  56710. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56711. * @param invertY defines if texture must be stored with Y axis inverted
  56712. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56713. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56714. */
  56715. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56716. /** Gets or sets the texture format to use */
  56717. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56718. /**
  56719. * Update the texture with new data
  56720. * @param data defines the data to store in the texture
  56721. */
  56722. update(data: ArrayBufferView): void;
  56723. }
  56724. }
  56725. declare module BABYLON {
  56726. /**
  56727. * Class used to store 2D array textures containing user data
  56728. */
  56729. export class RawTexture2DArray extends Texture {
  56730. /** Gets or sets the texture format to use */
  56731. format: number;
  56732. private _engine;
  56733. /**
  56734. * Create a new RawTexture2DArray
  56735. * @param data defines the data of the texture
  56736. * @param width defines the width of the texture
  56737. * @param height defines the height of the texture
  56738. * @param depth defines the number of layers of the texture
  56739. * @param format defines the texture format to use
  56740. * @param scene defines the hosting scene
  56741. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56742. * @param invertY defines if texture must be stored with Y axis inverted
  56743. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56745. */
  56746. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56747. /** Gets or sets the texture format to use */
  56748. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56749. /**
  56750. * Update the texture with new data
  56751. * @param data defines the data to store in the texture
  56752. */
  56753. update(data: ArrayBufferView): void;
  56754. }
  56755. }
  56756. declare module BABYLON {
  56757. /**
  56758. * Creates a refraction texture used by refraction channel of the standard material.
  56759. * It is like a mirror but to see through a material.
  56760. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56761. */
  56762. export class RefractionTexture extends RenderTargetTexture {
  56763. /**
  56764. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56765. * 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.
  56766. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56767. */
  56768. refractionPlane: Plane;
  56769. /**
  56770. * Define how deep under the surface we should see.
  56771. */
  56772. depth: number;
  56773. /**
  56774. * Creates a refraction texture used by refraction channel of the standard material.
  56775. * It is like a mirror but to see through a material.
  56776. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56777. * @param name Define the texture name
  56778. * @param size Define the size of the underlying texture
  56779. * @param scene Define the scene the refraction belongs to
  56780. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56781. */
  56782. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56783. /**
  56784. * Clone the refraction texture.
  56785. * @returns the cloned texture
  56786. */
  56787. clone(): RefractionTexture;
  56788. /**
  56789. * Serialize the texture to a JSON representation you could use in Parse later on
  56790. * @returns the serialized JSON representation
  56791. */
  56792. serialize(): any;
  56793. }
  56794. }
  56795. declare module BABYLON {
  56796. /**
  56797. * Defines the options related to the creation of an HtmlElementTexture
  56798. */
  56799. export interface IHtmlElementTextureOptions {
  56800. /**
  56801. * Defines wether mip maps should be created or not.
  56802. */
  56803. generateMipMaps?: boolean;
  56804. /**
  56805. * Defines the sampling mode of the texture.
  56806. */
  56807. samplingMode?: number;
  56808. /**
  56809. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56810. */
  56811. engine: Nullable<ThinEngine>;
  56812. /**
  56813. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56814. */
  56815. scene: Nullable<Scene>;
  56816. }
  56817. /**
  56818. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56819. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56820. * is automatically managed.
  56821. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56822. * in your application.
  56823. *
  56824. * As the update is not automatic, you need to call them manually.
  56825. */
  56826. export class HtmlElementTexture extends BaseTexture {
  56827. /**
  56828. * The texture URL.
  56829. */
  56830. element: HTMLVideoElement | HTMLCanvasElement;
  56831. private static readonly DefaultOptions;
  56832. private _textureMatrix;
  56833. private _engine;
  56834. private _isVideo;
  56835. private _generateMipMaps;
  56836. private _samplingMode;
  56837. /**
  56838. * Instantiates a HtmlElementTexture from the following parameters.
  56839. *
  56840. * @param name Defines the name of the texture
  56841. * @param element Defines the video or canvas the texture is filled with
  56842. * @param options Defines the other none mandatory texture creation options
  56843. */
  56844. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56845. private _createInternalTexture;
  56846. /**
  56847. * Returns the texture matrix used in most of the material.
  56848. */
  56849. getTextureMatrix(): Matrix;
  56850. /**
  56851. * Updates the content of the texture.
  56852. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56853. */
  56854. update(invertY?: Nullable<boolean>): void;
  56855. }
  56856. }
  56857. declare module BABYLON {
  56858. /**
  56859. * Defines the basic options interface of a TexturePacker Frame
  56860. */
  56861. export interface ITexturePackerFrame {
  56862. /**
  56863. * The frame ID
  56864. */
  56865. id: number;
  56866. /**
  56867. * The frames Scale
  56868. */
  56869. scale: Vector2;
  56870. /**
  56871. * The Frames offset
  56872. */
  56873. offset: Vector2;
  56874. }
  56875. /**
  56876. * This is a support class for frame Data on texture packer sets.
  56877. */
  56878. export class TexturePackerFrame implements ITexturePackerFrame {
  56879. /**
  56880. * The frame ID
  56881. */
  56882. id: number;
  56883. /**
  56884. * The frames Scale
  56885. */
  56886. scale: Vector2;
  56887. /**
  56888. * The Frames offset
  56889. */
  56890. offset: Vector2;
  56891. /**
  56892. * Initializes a texture package frame.
  56893. * @param id The numerical frame identifier
  56894. * @param scale Scalar Vector2 for UV frame
  56895. * @param offset Vector2 for the frame position in UV units.
  56896. * @returns TexturePackerFrame
  56897. */
  56898. constructor(id: number, scale: Vector2, offset: Vector2);
  56899. }
  56900. }
  56901. declare module BABYLON {
  56902. /**
  56903. * Defines the basic options interface of a TexturePacker
  56904. */
  56905. export interface ITexturePackerOptions {
  56906. /**
  56907. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56908. */
  56909. map?: string[];
  56910. /**
  56911. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56912. */
  56913. uvsIn?: string;
  56914. /**
  56915. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56916. */
  56917. uvsOut?: string;
  56918. /**
  56919. * number representing the layout style. Defaults to LAYOUT_STRIP
  56920. */
  56921. layout?: number;
  56922. /**
  56923. * number of columns if using custom column count layout(2). This defaults to 4.
  56924. */
  56925. colnum?: number;
  56926. /**
  56927. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56928. */
  56929. updateInputMeshes?: boolean;
  56930. /**
  56931. * boolean flag to dispose all the source textures. Defaults to true.
  56932. */
  56933. disposeSources?: boolean;
  56934. /**
  56935. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56936. */
  56937. fillBlanks?: boolean;
  56938. /**
  56939. * string value representing the context fill style color. Defaults to 'black'.
  56940. */
  56941. customFillColor?: string;
  56942. /**
  56943. * Width and Height Value of each Frame in the TexturePacker Sets
  56944. */
  56945. frameSize?: number;
  56946. /**
  56947. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56948. */
  56949. paddingRatio?: number;
  56950. /**
  56951. * Number that declares the fill method for the padding gutter.
  56952. */
  56953. paddingMode?: number;
  56954. /**
  56955. * If in SUBUV_COLOR padding mode what color to use.
  56956. */
  56957. paddingColor?: Color3 | Color4;
  56958. }
  56959. /**
  56960. * Defines the basic interface of a TexturePacker JSON File
  56961. */
  56962. export interface ITexturePackerJSON {
  56963. /**
  56964. * The frame ID
  56965. */
  56966. name: string;
  56967. /**
  56968. * The base64 channel data
  56969. */
  56970. sets: any;
  56971. /**
  56972. * The options of the Packer
  56973. */
  56974. options: ITexturePackerOptions;
  56975. /**
  56976. * The frame data of the Packer
  56977. */
  56978. frames: Array<number>;
  56979. }
  56980. /**
  56981. * This is a support class that generates a series of packed texture sets.
  56982. * @see https://doc.babylonjs.com/babylon101/materials
  56983. */
  56984. export class TexturePacker {
  56985. /** Packer Layout Constant 0 */
  56986. static readonly LAYOUT_STRIP: number;
  56987. /** Packer Layout Constant 1 */
  56988. static readonly LAYOUT_POWER2: number;
  56989. /** Packer Layout Constant 2 */
  56990. static readonly LAYOUT_COLNUM: number;
  56991. /** Packer Layout Constant 0 */
  56992. static readonly SUBUV_WRAP: number;
  56993. /** Packer Layout Constant 1 */
  56994. static readonly SUBUV_EXTEND: number;
  56995. /** Packer Layout Constant 2 */
  56996. static readonly SUBUV_COLOR: number;
  56997. /** The Name of the Texture Package */
  56998. name: string;
  56999. /** The scene scope of the TexturePacker */
  57000. scene: Scene;
  57001. /** The Meshes to target */
  57002. meshes: AbstractMesh[];
  57003. /** Arguments passed with the Constructor */
  57004. options: ITexturePackerOptions;
  57005. /** The promise that is started upon initialization */
  57006. promise: Nullable<Promise<TexturePacker | string>>;
  57007. /** The Container object for the channel sets that are generated */
  57008. sets: object;
  57009. /** The Container array for the frames that are generated */
  57010. frames: TexturePackerFrame[];
  57011. /** The expected number of textures the system is parsing. */
  57012. private _expecting;
  57013. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57014. private _paddingValue;
  57015. /**
  57016. * Initializes a texture package series from an array of meshes or a single mesh.
  57017. * @param name The name of the package
  57018. * @param meshes The target meshes to compose the package from
  57019. * @param options The arguments that texture packer should follow while building.
  57020. * @param scene The scene which the textures are scoped to.
  57021. * @returns TexturePacker
  57022. */
  57023. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57024. /**
  57025. * Starts the package process
  57026. * @param resolve The promises resolution function
  57027. * @returns TexturePacker
  57028. */
  57029. private _createFrames;
  57030. /**
  57031. * Calculates the Size of the Channel Sets
  57032. * @returns Vector2
  57033. */
  57034. private _calculateSize;
  57035. /**
  57036. * Calculates the UV data for the frames.
  57037. * @param baseSize the base frameSize
  57038. * @param padding the base frame padding
  57039. * @param dtSize size of the Dynamic Texture for that channel
  57040. * @param dtUnits is 1/dtSize
  57041. * @param update flag to update the input meshes
  57042. */
  57043. private _calculateMeshUVFrames;
  57044. /**
  57045. * Calculates the frames Offset.
  57046. * @param index of the frame
  57047. * @returns Vector2
  57048. */
  57049. private _getFrameOffset;
  57050. /**
  57051. * Updates a Mesh to the frame data
  57052. * @param mesh that is the target
  57053. * @param frameID or the frame index
  57054. */
  57055. private _updateMeshUV;
  57056. /**
  57057. * Updates a Meshes materials to use the texture packer channels
  57058. * @param m is the mesh to target
  57059. * @param force all channels on the packer to be set.
  57060. */
  57061. private _updateTextureReferences;
  57062. /**
  57063. * Public method to set a Mesh to a frame
  57064. * @param m that is the target
  57065. * @param frameID or the frame index
  57066. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57067. */
  57068. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57069. /**
  57070. * Starts the async promise to compile the texture packer.
  57071. * @returns Promise<void>
  57072. */
  57073. processAsync(): Promise<void>;
  57074. /**
  57075. * Disposes all textures associated with this packer
  57076. */
  57077. dispose(): void;
  57078. /**
  57079. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57080. * @param imageType is the image type to use.
  57081. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57082. */
  57083. download(imageType?: string, quality?: number): void;
  57084. /**
  57085. * Public method to load a texturePacker JSON file.
  57086. * @param data of the JSON file in string format.
  57087. */
  57088. updateFromJSON(data: string): void;
  57089. }
  57090. }
  57091. declare module BABYLON {
  57092. /**
  57093. * Enum used to define the target of a block
  57094. */
  57095. export enum NodeMaterialBlockTargets {
  57096. /** Vertex shader */
  57097. Vertex = 1,
  57098. /** Fragment shader */
  57099. Fragment = 2,
  57100. /** Neutral */
  57101. Neutral = 4,
  57102. /** Vertex and Fragment */
  57103. VertexAndFragment = 3
  57104. }
  57105. }
  57106. declare module BABYLON {
  57107. /**
  57108. * Defines the kind of connection point for node based material
  57109. */
  57110. export enum NodeMaterialBlockConnectionPointTypes {
  57111. /** Float */
  57112. Float = 1,
  57113. /** Int */
  57114. Int = 2,
  57115. /** Vector2 */
  57116. Vector2 = 4,
  57117. /** Vector3 */
  57118. Vector3 = 8,
  57119. /** Vector4 */
  57120. Vector4 = 16,
  57121. /** Color3 */
  57122. Color3 = 32,
  57123. /** Color4 */
  57124. Color4 = 64,
  57125. /** Matrix */
  57126. Matrix = 128,
  57127. /** Detect type based on connection */
  57128. AutoDetect = 1024,
  57129. /** Output type that will be defined by input type */
  57130. BasedOnInput = 2048
  57131. }
  57132. }
  57133. declare module BABYLON {
  57134. /**
  57135. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57136. */
  57137. export enum NodeMaterialBlockConnectionPointMode {
  57138. /** Value is an uniform */
  57139. Uniform = 0,
  57140. /** Value is a mesh attribute */
  57141. Attribute = 1,
  57142. /** Value is a varying between vertex and fragment shaders */
  57143. Varying = 2,
  57144. /** Mode is undefined */
  57145. Undefined = 3
  57146. }
  57147. }
  57148. declare module BABYLON {
  57149. /**
  57150. * Enum used to define system values e.g. values automatically provided by the system
  57151. */
  57152. export enum NodeMaterialSystemValues {
  57153. /** World */
  57154. World = 1,
  57155. /** View */
  57156. View = 2,
  57157. /** Projection */
  57158. Projection = 3,
  57159. /** ViewProjection */
  57160. ViewProjection = 4,
  57161. /** WorldView */
  57162. WorldView = 5,
  57163. /** WorldViewProjection */
  57164. WorldViewProjection = 6,
  57165. /** CameraPosition */
  57166. CameraPosition = 7,
  57167. /** Fog Color */
  57168. FogColor = 8,
  57169. /** Delta time */
  57170. DeltaTime = 9
  57171. }
  57172. }
  57173. declare module BABYLON {
  57174. /**
  57175. * Root class for all node material optimizers
  57176. */
  57177. export class NodeMaterialOptimizer {
  57178. /**
  57179. * Function used to optimize a NodeMaterial graph
  57180. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57181. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57182. */
  57183. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57184. }
  57185. }
  57186. declare module BABYLON {
  57187. /**
  57188. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57189. */
  57190. export class TransformBlock extends NodeMaterialBlock {
  57191. /**
  57192. * Defines the value to use to complement W value to transform it to a Vector4
  57193. */
  57194. complementW: number;
  57195. /**
  57196. * Defines the value to use to complement z value to transform it to a Vector4
  57197. */
  57198. complementZ: number;
  57199. /**
  57200. * Creates a new TransformBlock
  57201. * @param name defines the block name
  57202. */
  57203. constructor(name: string);
  57204. /**
  57205. * Gets the current class name
  57206. * @returns the class name
  57207. */
  57208. getClassName(): string;
  57209. /**
  57210. * Gets the vector input
  57211. */
  57212. get vector(): NodeMaterialConnectionPoint;
  57213. /**
  57214. * Gets the output component
  57215. */
  57216. get output(): NodeMaterialConnectionPoint;
  57217. /**
  57218. * Gets the xyz output component
  57219. */
  57220. get xyz(): NodeMaterialConnectionPoint;
  57221. /**
  57222. * Gets the matrix transform input
  57223. */
  57224. get transform(): NodeMaterialConnectionPoint;
  57225. protected _buildBlock(state: NodeMaterialBuildState): this;
  57226. serialize(): any;
  57227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57228. protected _dumpPropertiesCode(): string;
  57229. }
  57230. }
  57231. declare module BABYLON {
  57232. /**
  57233. * Block used to output the vertex position
  57234. */
  57235. export class VertexOutputBlock extends NodeMaterialBlock {
  57236. /**
  57237. * Creates a new VertexOutputBlock
  57238. * @param name defines the block name
  57239. */
  57240. constructor(name: string);
  57241. /**
  57242. * Gets the current class name
  57243. * @returns the class name
  57244. */
  57245. getClassName(): string;
  57246. /**
  57247. * Gets the vector input component
  57248. */
  57249. get vector(): NodeMaterialConnectionPoint;
  57250. protected _buildBlock(state: NodeMaterialBuildState): this;
  57251. }
  57252. }
  57253. declare module BABYLON {
  57254. /**
  57255. * Block used to output the final color
  57256. */
  57257. export class FragmentOutputBlock extends NodeMaterialBlock {
  57258. /**
  57259. * Create a new FragmentOutputBlock
  57260. * @param name defines the block name
  57261. */
  57262. constructor(name: string);
  57263. /**
  57264. * Gets the current class name
  57265. * @returns the class name
  57266. */
  57267. getClassName(): string;
  57268. /**
  57269. * Gets the rgba input component
  57270. */
  57271. get rgba(): NodeMaterialConnectionPoint;
  57272. /**
  57273. * Gets the rgb input component
  57274. */
  57275. get rgb(): NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the a input component
  57278. */
  57279. get a(): NodeMaterialConnectionPoint;
  57280. protected _buildBlock(state: NodeMaterialBuildState): this;
  57281. }
  57282. }
  57283. declare module BABYLON {
  57284. /**
  57285. * Block used to read a reflection texture from a sampler
  57286. */
  57287. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57288. private _define3DName;
  57289. private _defineCubicName;
  57290. private _defineExplicitName;
  57291. private _defineProjectionName;
  57292. private _defineLocalCubicName;
  57293. private _defineSphericalName;
  57294. private _definePlanarName;
  57295. private _defineEquirectangularName;
  57296. private _defineMirroredEquirectangularFixedName;
  57297. private _defineEquirectangularFixedName;
  57298. private _defineSkyboxName;
  57299. private _cubeSamplerName;
  57300. private _2DSamplerName;
  57301. private _positionUVWName;
  57302. private _directionWName;
  57303. private _reflectionCoordsName;
  57304. private _reflection2DCoordsName;
  57305. private _reflectionColorName;
  57306. private _reflectionMatrixName;
  57307. /**
  57308. * Gets or sets the texture associated with the node
  57309. */
  57310. texture: Nullable<BaseTexture>;
  57311. /**
  57312. * Create a new TextureBlock
  57313. * @param name defines the block name
  57314. */
  57315. constructor(name: string);
  57316. /**
  57317. * Gets the current class name
  57318. * @returns the class name
  57319. */
  57320. getClassName(): string;
  57321. /**
  57322. * Gets the world position input component
  57323. */
  57324. get position(): NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the world position input component
  57327. */
  57328. get worldPosition(): NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the world normal input component
  57331. */
  57332. get worldNormal(): NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the world input component
  57335. */
  57336. get world(): NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the camera (or eye) position component
  57339. */
  57340. get cameraPosition(): NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the view input component
  57343. */
  57344. get view(): NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the rgb output component
  57347. */
  57348. get rgb(): NodeMaterialConnectionPoint;
  57349. /**
  57350. * Gets the r output component
  57351. */
  57352. get r(): NodeMaterialConnectionPoint;
  57353. /**
  57354. * Gets the g output component
  57355. */
  57356. get g(): NodeMaterialConnectionPoint;
  57357. /**
  57358. * Gets the b output component
  57359. */
  57360. get b(): NodeMaterialConnectionPoint;
  57361. autoConfigure(material: NodeMaterial): void;
  57362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57363. isReady(): boolean;
  57364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57365. private _injectVertexCode;
  57366. private _writeOutput;
  57367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57368. protected _dumpPropertiesCode(): string;
  57369. serialize(): any;
  57370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57371. }
  57372. }
  57373. declare module BABYLON {
  57374. /**
  57375. * Interface used to configure the node material editor
  57376. */
  57377. export interface INodeMaterialEditorOptions {
  57378. /** Define the URl to load node editor script */
  57379. editorURL?: string;
  57380. }
  57381. /** @hidden */
  57382. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57383. NORMAL: boolean;
  57384. TANGENT: boolean;
  57385. UV1: boolean;
  57386. /** BONES */
  57387. NUM_BONE_INFLUENCERS: number;
  57388. BonesPerMesh: number;
  57389. BONETEXTURE: boolean;
  57390. /** MORPH TARGETS */
  57391. MORPHTARGETS: boolean;
  57392. MORPHTARGETS_NORMAL: boolean;
  57393. MORPHTARGETS_TANGENT: boolean;
  57394. MORPHTARGETS_UV: boolean;
  57395. NUM_MORPH_INFLUENCERS: number;
  57396. /** IMAGE PROCESSING */
  57397. IMAGEPROCESSING: boolean;
  57398. VIGNETTE: boolean;
  57399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57400. VIGNETTEBLENDMODEOPAQUE: boolean;
  57401. TONEMAPPING: boolean;
  57402. TONEMAPPING_ACES: boolean;
  57403. CONTRAST: boolean;
  57404. EXPOSURE: boolean;
  57405. COLORCURVES: boolean;
  57406. COLORGRADING: boolean;
  57407. COLORGRADING3D: boolean;
  57408. SAMPLER3DGREENDEPTH: boolean;
  57409. SAMPLER3DBGRMAP: boolean;
  57410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57411. /** MISC. */
  57412. BUMPDIRECTUV: number;
  57413. constructor();
  57414. setValue(name: string, value: boolean): void;
  57415. }
  57416. /**
  57417. * Class used to configure NodeMaterial
  57418. */
  57419. export interface INodeMaterialOptions {
  57420. /**
  57421. * Defines if blocks should emit comments
  57422. */
  57423. emitComments: boolean;
  57424. }
  57425. /**
  57426. * Class used to create a node based material built by assembling shader blocks
  57427. */
  57428. export class NodeMaterial extends PushMaterial {
  57429. private static _BuildIdGenerator;
  57430. private _options;
  57431. private _vertexCompilationState;
  57432. private _fragmentCompilationState;
  57433. private _sharedData;
  57434. private _buildId;
  57435. private _buildWasSuccessful;
  57436. private _cachedWorldViewMatrix;
  57437. private _cachedWorldViewProjectionMatrix;
  57438. private _optimizers;
  57439. private _animationFrame;
  57440. /** Define the Url to load node editor script */
  57441. static EditorURL: string;
  57442. /** Define the Url to load snippets */
  57443. static SnippetUrl: string;
  57444. private BJSNODEMATERIALEDITOR;
  57445. /** Get the inspector from bundle or global */
  57446. private _getGlobalNodeMaterialEditor;
  57447. /**
  57448. * Gets or sets data used by visual editor
  57449. * @see https://nme.babylonjs.com
  57450. */
  57451. editorData: any;
  57452. /**
  57453. * 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)
  57454. */
  57455. ignoreAlpha: boolean;
  57456. /**
  57457. * Defines the maximum number of lights that can be used in the material
  57458. */
  57459. maxSimultaneousLights: number;
  57460. /**
  57461. * Observable raised when the material is built
  57462. */
  57463. onBuildObservable: Observable<NodeMaterial>;
  57464. /**
  57465. * Gets or sets the root nodes of the material vertex shader
  57466. */
  57467. _vertexOutputNodes: NodeMaterialBlock[];
  57468. /**
  57469. * Gets or sets the root nodes of the material fragment (pixel) shader
  57470. */
  57471. _fragmentOutputNodes: NodeMaterialBlock[];
  57472. /** Gets or sets options to control the node material overall behavior */
  57473. get options(): INodeMaterialOptions;
  57474. set options(options: INodeMaterialOptions);
  57475. /**
  57476. * Default configuration related to image processing available in the standard Material.
  57477. */
  57478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57479. /**
  57480. * Gets the image processing configuration used either in this material.
  57481. */
  57482. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57483. /**
  57484. * Sets the Default image processing configuration used either in the this material.
  57485. *
  57486. * If sets to null, the scene one is in use.
  57487. */
  57488. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57489. /**
  57490. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57491. */
  57492. attachedBlocks: NodeMaterialBlock[];
  57493. /**
  57494. * Create a new node based material
  57495. * @param name defines the material name
  57496. * @param scene defines the hosting scene
  57497. * @param options defines creation option
  57498. */
  57499. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57500. /**
  57501. * Gets the current class name of the material e.g. "NodeMaterial"
  57502. * @returns the class name
  57503. */
  57504. getClassName(): string;
  57505. /**
  57506. * Keep track of the image processing observer to allow dispose and replace.
  57507. */
  57508. private _imageProcessingObserver;
  57509. /**
  57510. * Attaches a new image processing configuration to the Standard Material.
  57511. * @param configuration
  57512. */
  57513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57514. /**
  57515. * Get a block by its name
  57516. * @param name defines the name of the block to retrieve
  57517. * @returns the required block or null if not found
  57518. */
  57519. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57520. /**
  57521. * Get a block by its name
  57522. * @param predicate defines the predicate used to find the good candidate
  57523. * @returns the required block or null if not found
  57524. */
  57525. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57526. /**
  57527. * Get an input block by its name
  57528. * @param predicate defines the predicate used to find the good candidate
  57529. * @returns the required input block or null if not found
  57530. */
  57531. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57532. /**
  57533. * Gets the list of input blocks attached to this material
  57534. * @returns an array of InputBlocks
  57535. */
  57536. getInputBlocks(): InputBlock[];
  57537. /**
  57538. * Adds a new optimizer to the list of optimizers
  57539. * @param optimizer defines the optimizers to add
  57540. * @returns the current material
  57541. */
  57542. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57543. /**
  57544. * Remove an optimizer from the list of optimizers
  57545. * @param optimizer defines the optimizers to remove
  57546. * @returns the current material
  57547. */
  57548. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57549. /**
  57550. * Add a new block to the list of output nodes
  57551. * @param node defines the node to add
  57552. * @returns the current material
  57553. */
  57554. addOutputNode(node: NodeMaterialBlock): this;
  57555. /**
  57556. * Remove a block from the list of root nodes
  57557. * @param node defines the node to remove
  57558. * @returns the current material
  57559. */
  57560. removeOutputNode(node: NodeMaterialBlock): this;
  57561. private _addVertexOutputNode;
  57562. private _removeVertexOutputNode;
  57563. private _addFragmentOutputNode;
  57564. private _removeFragmentOutputNode;
  57565. /**
  57566. * Specifies if the material will require alpha blending
  57567. * @returns a boolean specifying if alpha blending is needed
  57568. */
  57569. needAlphaBlending(): boolean;
  57570. /**
  57571. * Specifies if this material should be rendered in alpha test mode
  57572. * @returns a boolean specifying if an alpha test is needed.
  57573. */
  57574. needAlphaTesting(): boolean;
  57575. private _initializeBlock;
  57576. private _resetDualBlocks;
  57577. /**
  57578. * Remove a block from the current node material
  57579. * @param block defines the block to remove
  57580. */
  57581. removeBlock(block: NodeMaterialBlock): void;
  57582. /**
  57583. * Build the material and generates the inner effect
  57584. * @param verbose defines if the build should log activity
  57585. */
  57586. build(verbose?: boolean): void;
  57587. /**
  57588. * Runs an otpimization phase to try to improve the shader code
  57589. */
  57590. optimize(): void;
  57591. private _prepareDefinesForAttributes;
  57592. /**
  57593. * Get if the submesh is ready to be used and all its information available.
  57594. * Child classes can use it to update shaders
  57595. * @param mesh defines the mesh to check
  57596. * @param subMesh defines which submesh to check
  57597. * @param useInstances specifies that instances should be used
  57598. * @returns a boolean indicating that the submesh is ready or not
  57599. */
  57600. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57601. /**
  57602. * Get a string representing the shaders built by the current node graph
  57603. */
  57604. get compiledShaders(): string;
  57605. /**
  57606. * Binds the world matrix to the material
  57607. * @param world defines the world transformation matrix
  57608. */
  57609. bindOnlyWorldMatrix(world: Matrix): void;
  57610. /**
  57611. * Binds the submesh to this material by preparing the effect and shader to draw
  57612. * @param world defines the world transformation matrix
  57613. * @param mesh defines the mesh containing the submesh
  57614. * @param subMesh defines the submesh to bind the material to
  57615. */
  57616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57617. /**
  57618. * Gets the active textures from the material
  57619. * @returns an array of textures
  57620. */
  57621. getActiveTextures(): BaseTexture[];
  57622. /**
  57623. * Gets the list of texture blocks
  57624. * @returns an array of texture blocks
  57625. */
  57626. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57627. /**
  57628. * Specifies if the material uses a texture
  57629. * @param texture defines the texture to check against the material
  57630. * @returns a boolean specifying if the material uses the texture
  57631. */
  57632. hasTexture(texture: BaseTexture): boolean;
  57633. /**
  57634. * Disposes the material
  57635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57638. */
  57639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57640. /** Creates the node editor window. */
  57641. private _createNodeEditor;
  57642. /**
  57643. * Launch the node material editor
  57644. * @param config Define the configuration of the editor
  57645. * @return a promise fulfilled when the node editor is visible
  57646. */
  57647. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57648. /**
  57649. * Clear the current material
  57650. */
  57651. clear(): void;
  57652. /**
  57653. * Clear the current material and set it to a default state
  57654. */
  57655. setToDefault(): void;
  57656. /**
  57657. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57658. * @param url defines the url to load from
  57659. * @returns a promise that will fullfil when the material is fully loaded
  57660. */
  57661. loadAsync(url: string): Promise<void>;
  57662. private _gatherBlocks;
  57663. /**
  57664. * Generate a string containing the code declaration required to create an equivalent of this material
  57665. * @returns a string
  57666. */
  57667. generateCode(): string;
  57668. /**
  57669. * Serializes this material in a JSON representation
  57670. * @returns the serialized material object
  57671. */
  57672. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57673. private _restoreConnections;
  57674. /**
  57675. * Clear the current graph and load a new one from a serialization object
  57676. * @param source defines the JSON representation of the material
  57677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57678. */
  57679. loadFromSerialization(source: any, rootUrl?: string): void;
  57680. /**
  57681. * Makes a duplicate of the current material.
  57682. * @param name - name to use for the new material.
  57683. */
  57684. clone(name: string): NodeMaterial;
  57685. /**
  57686. * Creates a node material from parsed material data
  57687. * @param source defines the JSON representation of the material
  57688. * @param scene defines the hosting scene
  57689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57690. * @returns a new node material
  57691. */
  57692. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57693. /**
  57694. * Creates a node material from a snippet saved in a remote file
  57695. * @param name defines the name of the material to create
  57696. * @param url defines the url to load from
  57697. * @param scene defines the hosting scene
  57698. * @returns a promise that will resolve to the new node material
  57699. */
  57700. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57701. /**
  57702. * Creates a node material from a snippet saved by the node material editor
  57703. * @param snippetId defines the snippet to load
  57704. * @param scene defines the hosting scene
  57705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57706. * @returns a promise that will resolve to the new node material
  57707. */
  57708. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57709. /**
  57710. * Creates a new node material set to default basic configuration
  57711. * @param name defines the name of the material
  57712. * @param scene defines the hosting scene
  57713. * @returns a new NodeMaterial
  57714. */
  57715. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57716. }
  57717. }
  57718. declare module BABYLON {
  57719. /**
  57720. * Block used to read a texture from a sampler
  57721. */
  57722. export class TextureBlock extends NodeMaterialBlock {
  57723. private _defineName;
  57724. private _linearDefineName;
  57725. private _tempTextureRead;
  57726. private _samplerName;
  57727. private _transformedUVName;
  57728. private _textureTransformName;
  57729. private _textureInfoName;
  57730. private _mainUVName;
  57731. private _mainUVDefineName;
  57732. /**
  57733. * Gets or sets the texture associated with the node
  57734. */
  57735. texture: Nullable<Texture>;
  57736. /**
  57737. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57738. */
  57739. convertToGammaSpace: boolean;
  57740. /**
  57741. * Create a new TextureBlock
  57742. * @param name defines the block name
  57743. */
  57744. constructor(name: string);
  57745. /**
  57746. * Gets the current class name
  57747. * @returns the class name
  57748. */
  57749. getClassName(): string;
  57750. /**
  57751. * Gets the uv input component
  57752. */
  57753. get uv(): NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the rgba output component
  57756. */
  57757. get rgba(): NodeMaterialConnectionPoint;
  57758. /**
  57759. * Gets the rgb output component
  57760. */
  57761. get rgb(): NodeMaterialConnectionPoint;
  57762. /**
  57763. * Gets the r output component
  57764. */
  57765. get r(): NodeMaterialConnectionPoint;
  57766. /**
  57767. * Gets the g output component
  57768. */
  57769. get g(): NodeMaterialConnectionPoint;
  57770. /**
  57771. * Gets the b output component
  57772. */
  57773. get b(): NodeMaterialConnectionPoint;
  57774. /**
  57775. * Gets the a output component
  57776. */
  57777. get a(): NodeMaterialConnectionPoint;
  57778. get target(): NodeMaterialBlockTargets;
  57779. autoConfigure(material: NodeMaterial): void;
  57780. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57782. isReady(): boolean;
  57783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57784. private get _isMixed();
  57785. private _injectVertexCode;
  57786. private _writeTextureRead;
  57787. private _writeOutput;
  57788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57789. protected _dumpPropertiesCode(): string;
  57790. serialize(): any;
  57791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57792. }
  57793. }
  57794. declare module BABYLON {
  57795. /**
  57796. * Class used to store shared data between 2 NodeMaterialBuildState
  57797. */
  57798. export class NodeMaterialBuildStateSharedData {
  57799. /**
  57800. * Gets the list of emitted varyings
  57801. */
  57802. temps: string[];
  57803. /**
  57804. * Gets the list of emitted varyings
  57805. */
  57806. varyings: string[];
  57807. /**
  57808. * Gets the varying declaration string
  57809. */
  57810. varyingDeclaration: string;
  57811. /**
  57812. * Input blocks
  57813. */
  57814. inputBlocks: InputBlock[];
  57815. /**
  57816. * Input blocks
  57817. */
  57818. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57819. /**
  57820. * Bindable blocks (Blocks that need to set data to the effect)
  57821. */
  57822. bindableBlocks: NodeMaterialBlock[];
  57823. /**
  57824. * List of blocks that can provide a compilation fallback
  57825. */
  57826. blocksWithFallbacks: NodeMaterialBlock[];
  57827. /**
  57828. * List of blocks that can provide a define update
  57829. */
  57830. blocksWithDefines: NodeMaterialBlock[];
  57831. /**
  57832. * List of blocks that can provide a repeatable content
  57833. */
  57834. repeatableContentBlocks: NodeMaterialBlock[];
  57835. /**
  57836. * List of blocks that can provide a dynamic list of uniforms
  57837. */
  57838. dynamicUniformBlocks: NodeMaterialBlock[];
  57839. /**
  57840. * List of blocks that can block the isReady function for the material
  57841. */
  57842. blockingBlocks: NodeMaterialBlock[];
  57843. /**
  57844. * Gets the list of animated inputs
  57845. */
  57846. animatedInputs: InputBlock[];
  57847. /**
  57848. * Build Id used to avoid multiple recompilations
  57849. */
  57850. buildId: number;
  57851. /** List of emitted variables */
  57852. variableNames: {
  57853. [key: string]: number;
  57854. };
  57855. /** List of emitted defines */
  57856. defineNames: {
  57857. [key: string]: number;
  57858. };
  57859. /** Should emit comments? */
  57860. emitComments: boolean;
  57861. /** Emit build activity */
  57862. verbose: boolean;
  57863. /** Gets or sets the hosting scene */
  57864. scene: Scene;
  57865. /**
  57866. * Gets the compilation hints emitted at compilation time
  57867. */
  57868. hints: {
  57869. needWorldViewMatrix: boolean;
  57870. needWorldViewProjectionMatrix: boolean;
  57871. needAlphaBlending: boolean;
  57872. needAlphaTesting: boolean;
  57873. };
  57874. /**
  57875. * List of compilation checks
  57876. */
  57877. checks: {
  57878. emitVertex: boolean;
  57879. emitFragment: boolean;
  57880. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57881. };
  57882. /** Creates a new shared data */
  57883. constructor();
  57884. /**
  57885. * Emits console errors and exceptions if there is a failing check
  57886. */
  57887. emitErrors(): void;
  57888. }
  57889. }
  57890. declare module BABYLON {
  57891. /**
  57892. * Class used to store node based material build state
  57893. */
  57894. export class NodeMaterialBuildState {
  57895. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57896. supportUniformBuffers: boolean;
  57897. /**
  57898. * Gets the list of emitted attributes
  57899. */
  57900. attributes: string[];
  57901. /**
  57902. * Gets the list of emitted uniforms
  57903. */
  57904. uniforms: string[];
  57905. /**
  57906. * Gets the list of emitted constants
  57907. */
  57908. constants: string[];
  57909. /**
  57910. * Gets the list of emitted samplers
  57911. */
  57912. samplers: string[];
  57913. /**
  57914. * Gets the list of emitted functions
  57915. */
  57916. functions: {
  57917. [key: string]: string;
  57918. };
  57919. /**
  57920. * Gets the list of emitted extensions
  57921. */
  57922. extensions: {
  57923. [key: string]: string;
  57924. };
  57925. /**
  57926. * Gets the target of the compilation state
  57927. */
  57928. target: NodeMaterialBlockTargets;
  57929. /**
  57930. * Gets the list of emitted counters
  57931. */
  57932. counters: {
  57933. [key: string]: number;
  57934. };
  57935. /**
  57936. * Shared data between multiple NodeMaterialBuildState instances
  57937. */
  57938. sharedData: NodeMaterialBuildStateSharedData;
  57939. /** @hidden */
  57940. _vertexState: NodeMaterialBuildState;
  57941. /** @hidden */
  57942. _attributeDeclaration: string;
  57943. /** @hidden */
  57944. _uniformDeclaration: string;
  57945. /** @hidden */
  57946. _constantDeclaration: string;
  57947. /** @hidden */
  57948. _samplerDeclaration: string;
  57949. /** @hidden */
  57950. _varyingTransfer: string;
  57951. private _repeatableContentAnchorIndex;
  57952. /** @hidden */
  57953. _builtCompilationString: string;
  57954. /**
  57955. * Gets the emitted compilation strings
  57956. */
  57957. compilationString: string;
  57958. /**
  57959. * Finalize the compilation strings
  57960. * @param state defines the current compilation state
  57961. */
  57962. finalize(state: NodeMaterialBuildState): void;
  57963. /** @hidden */
  57964. get _repeatableContentAnchor(): string;
  57965. /** @hidden */
  57966. _getFreeVariableName(prefix: string): string;
  57967. /** @hidden */
  57968. _getFreeDefineName(prefix: string): string;
  57969. /** @hidden */
  57970. _excludeVariableName(name: string): void;
  57971. /** @hidden */
  57972. _emit2DSampler(name: string): void;
  57973. /** @hidden */
  57974. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57975. /** @hidden */
  57976. _emitExtension(name: string, extension: string): void;
  57977. /** @hidden */
  57978. _emitFunction(name: string, code: string, comments: string): void;
  57979. /** @hidden */
  57980. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57981. replaceStrings?: {
  57982. search: RegExp;
  57983. replace: string;
  57984. }[];
  57985. repeatKey?: string;
  57986. }): string;
  57987. /** @hidden */
  57988. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57989. repeatKey?: string;
  57990. removeAttributes?: boolean;
  57991. removeUniforms?: boolean;
  57992. removeVaryings?: boolean;
  57993. removeIfDef?: boolean;
  57994. replaceStrings?: {
  57995. search: RegExp;
  57996. replace: string;
  57997. }[];
  57998. }, storeKey?: string): void;
  57999. /** @hidden */
  58000. _registerTempVariable(name: string): boolean;
  58001. /** @hidden */
  58002. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58003. /** @hidden */
  58004. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58005. /** @hidden */
  58006. _emitFloat(value: number): string;
  58007. }
  58008. }
  58009. declare module BABYLON {
  58010. /**
  58011. * Defines a block that can be used inside a node based material
  58012. */
  58013. export class NodeMaterialBlock {
  58014. private _buildId;
  58015. private _buildTarget;
  58016. private _target;
  58017. private _isFinalMerger;
  58018. private _isInput;
  58019. protected _isUnique: boolean;
  58020. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58021. inputsAreExclusive: boolean;
  58022. /** @hidden */
  58023. _codeVariableName: string;
  58024. /** @hidden */
  58025. _inputs: NodeMaterialConnectionPoint[];
  58026. /** @hidden */
  58027. _outputs: NodeMaterialConnectionPoint[];
  58028. /** @hidden */
  58029. _preparationId: number;
  58030. /**
  58031. * Gets or sets the name of the block
  58032. */
  58033. name: string;
  58034. /**
  58035. * Gets or sets the unique id of the node
  58036. */
  58037. uniqueId: number;
  58038. /**
  58039. * Gets or sets the comments associated with this block
  58040. */
  58041. comments: string;
  58042. /**
  58043. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58044. */
  58045. get isUnique(): boolean;
  58046. /**
  58047. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58048. */
  58049. get isFinalMerger(): boolean;
  58050. /**
  58051. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58052. */
  58053. get isInput(): boolean;
  58054. /**
  58055. * Gets or sets the build Id
  58056. */
  58057. get buildId(): number;
  58058. set buildId(value: number);
  58059. /**
  58060. * Gets or sets the target of the block
  58061. */
  58062. get target(): NodeMaterialBlockTargets;
  58063. set target(value: NodeMaterialBlockTargets);
  58064. /**
  58065. * Gets the list of input points
  58066. */
  58067. get inputs(): NodeMaterialConnectionPoint[];
  58068. /** Gets the list of output points */
  58069. get outputs(): NodeMaterialConnectionPoint[];
  58070. /**
  58071. * Find an input by its name
  58072. * @param name defines the name of the input to look for
  58073. * @returns the input or null if not found
  58074. */
  58075. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58076. /**
  58077. * Find an output by its name
  58078. * @param name defines the name of the outputto look for
  58079. * @returns the output or null if not found
  58080. */
  58081. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58082. /**
  58083. * Creates a new NodeMaterialBlock
  58084. * @param name defines the block name
  58085. * @param target defines the target of that block (Vertex by default)
  58086. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58087. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58088. */
  58089. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58090. /**
  58091. * Initialize the block and prepare the context for build
  58092. * @param state defines the state that will be used for the build
  58093. */
  58094. initialize(state: NodeMaterialBuildState): void;
  58095. /**
  58096. * Bind data to effect. Will only be called for blocks with isBindable === true
  58097. * @param effect defines the effect to bind data to
  58098. * @param nodeMaterial defines the hosting NodeMaterial
  58099. * @param mesh defines the mesh that will be rendered
  58100. */
  58101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58102. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58103. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58104. protected _writeFloat(value: number): string;
  58105. /**
  58106. * Gets the current class name e.g. "NodeMaterialBlock"
  58107. * @returns the class name
  58108. */
  58109. getClassName(): string;
  58110. /**
  58111. * Register a new input. Must be called inside a block constructor
  58112. * @param name defines the connection point name
  58113. * @param type defines the connection point type
  58114. * @param isOptional defines a boolean indicating that this input can be omitted
  58115. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58116. * @returns the current block
  58117. */
  58118. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58119. /**
  58120. * Register a new output. Must be called inside a block constructor
  58121. * @param name defines the connection point name
  58122. * @param type defines the connection point type
  58123. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58124. * @returns the current block
  58125. */
  58126. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58127. /**
  58128. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58129. * @param forOutput defines an optional connection point to check compatibility with
  58130. * @returns the first available input or null
  58131. */
  58132. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58133. /**
  58134. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58135. * @param forBlock defines an optional block to check compatibility with
  58136. * @returns the first available input or null
  58137. */
  58138. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58139. /**
  58140. * Gets the sibling of the given output
  58141. * @param current defines the current output
  58142. * @returns the next output in the list or null
  58143. */
  58144. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58145. /**
  58146. * Connect current block with another block
  58147. * @param other defines the block to connect with
  58148. * @param options define the various options to help pick the right connections
  58149. * @returns the current block
  58150. */
  58151. connectTo(other: NodeMaterialBlock, options?: {
  58152. input?: string;
  58153. output?: string;
  58154. outputSwizzle?: string;
  58155. }): this | undefined;
  58156. protected _buildBlock(state: NodeMaterialBuildState): void;
  58157. /**
  58158. * Add uniforms, samplers and uniform buffers at compilation time
  58159. * @param state defines the state to update
  58160. * @param nodeMaterial defines the node material requesting the update
  58161. * @param defines defines the material defines to update
  58162. * @param uniformBuffers defines the list of uniform buffer names
  58163. */
  58164. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58165. /**
  58166. * Add potential fallbacks if shader compilation fails
  58167. * @param mesh defines the mesh to be rendered
  58168. * @param fallbacks defines the current prioritized list of fallbacks
  58169. */
  58170. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58171. /**
  58172. * Initialize defines for shader compilation
  58173. * @param mesh defines the mesh to be rendered
  58174. * @param nodeMaterial defines the node material requesting the update
  58175. * @param defines defines the material defines to update
  58176. * @param useInstances specifies that instances should be used
  58177. */
  58178. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58179. /**
  58180. * Update defines for shader compilation
  58181. * @param mesh defines the mesh to be rendered
  58182. * @param nodeMaterial defines the node material requesting the update
  58183. * @param defines defines the material defines to update
  58184. * @param useInstances specifies that instances should be used
  58185. */
  58186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58187. /**
  58188. * Lets the block try to connect some inputs automatically
  58189. * @param material defines the hosting NodeMaterial
  58190. */
  58191. autoConfigure(material: NodeMaterial): void;
  58192. /**
  58193. * Function called when a block is declared as repeatable content generator
  58194. * @param vertexShaderState defines the current compilation state for the vertex shader
  58195. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58196. * @param mesh defines the mesh to be rendered
  58197. * @param defines defines the material defines to update
  58198. */
  58199. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58200. /**
  58201. * Checks if the block is ready
  58202. * @param mesh defines the mesh to be rendered
  58203. * @param nodeMaterial defines the node material requesting the update
  58204. * @param defines defines the material defines to update
  58205. * @param useInstances specifies that instances should be used
  58206. * @returns true if the block is ready
  58207. */
  58208. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58209. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58210. private _processBuild;
  58211. /**
  58212. * Compile the current node and generate the shader code
  58213. * @param state defines the current compilation state (uniforms, samplers, current string)
  58214. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58215. * @returns true if already built
  58216. */
  58217. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58218. protected _inputRename(name: string): string;
  58219. protected _outputRename(name: string): string;
  58220. protected _dumpPropertiesCode(): string;
  58221. /** @hidden */
  58222. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58223. /** @hidden */
  58224. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58225. /**
  58226. * Clone the current block to a new identical block
  58227. * @param scene defines the hosting scene
  58228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58229. * @returns a copy of the current block
  58230. */
  58231. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58232. /**
  58233. * Serializes this block in a JSON representation
  58234. * @returns the serialized block object
  58235. */
  58236. serialize(): any;
  58237. /** @hidden */
  58238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58239. /**
  58240. * Release resources
  58241. */
  58242. dispose(): void;
  58243. }
  58244. }
  58245. declare module BABYLON {
  58246. /**
  58247. * Enum defining the type of animations supported by InputBlock
  58248. */
  58249. export enum AnimatedInputBlockTypes {
  58250. /** No animation */
  58251. None = 0,
  58252. /** Time based animation. Will only work for floats */
  58253. Time = 1
  58254. }
  58255. }
  58256. declare module BABYLON {
  58257. /**
  58258. * Block used to expose an input value
  58259. */
  58260. export class InputBlock extends NodeMaterialBlock {
  58261. private _mode;
  58262. private _associatedVariableName;
  58263. private _storedValue;
  58264. private _valueCallback;
  58265. private _type;
  58266. private _animationType;
  58267. /** Gets or set a value used to limit the range of float values */
  58268. min: number;
  58269. /** Gets or set a value used to limit the range of float values */
  58270. max: number;
  58271. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58272. isBoolean: boolean;
  58273. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58274. matrixMode: number;
  58275. /** @hidden */
  58276. _systemValue: Nullable<NodeMaterialSystemValues>;
  58277. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58278. visibleInInspector: boolean;
  58279. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58280. isConstant: boolean;
  58281. /** Gets or sets the group to use to display this block in the Inspector */
  58282. groupInInspector: string;
  58283. /** Gets an observable raised when the value is changed */
  58284. onValueChangedObservable: Observable<InputBlock>;
  58285. /**
  58286. * Gets or sets the connection point type (default is float)
  58287. */
  58288. get type(): NodeMaterialBlockConnectionPointTypes;
  58289. /**
  58290. * Creates a new InputBlock
  58291. * @param name defines the block name
  58292. * @param target defines the target of that block (Vertex by default)
  58293. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58294. */
  58295. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58296. /**
  58297. * Gets the output component
  58298. */
  58299. get output(): NodeMaterialConnectionPoint;
  58300. /**
  58301. * Set the source of this connection point to a vertex attribute
  58302. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58303. * @returns the current connection point
  58304. */
  58305. setAsAttribute(attributeName?: string): InputBlock;
  58306. /**
  58307. * Set the source of this connection point to a system value
  58308. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58309. * @returns the current connection point
  58310. */
  58311. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58312. /**
  58313. * Gets or sets the value of that point.
  58314. * Please note that this value will be ignored if valueCallback is defined
  58315. */
  58316. get value(): any;
  58317. set value(value: any);
  58318. /**
  58319. * Gets or sets a callback used to get the value of that point.
  58320. * Please note that setting this value will force the connection point to ignore the value property
  58321. */
  58322. get valueCallback(): () => any;
  58323. set valueCallback(value: () => any);
  58324. /**
  58325. * Gets or sets the associated variable name in the shader
  58326. */
  58327. get associatedVariableName(): string;
  58328. set associatedVariableName(value: string);
  58329. /** Gets or sets the type of animation applied to the input */
  58330. get animationType(): AnimatedInputBlockTypes;
  58331. set animationType(value: AnimatedInputBlockTypes);
  58332. /**
  58333. * Gets a boolean indicating that this connection point not defined yet
  58334. */
  58335. get isUndefined(): boolean;
  58336. /**
  58337. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58338. * In this case the connection point name must be the name of the uniform to use.
  58339. * Can only be set on inputs
  58340. */
  58341. get isUniform(): boolean;
  58342. set isUniform(value: boolean);
  58343. /**
  58344. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58345. * In this case the connection point name must be the name of the attribute to use
  58346. * Can only be set on inputs
  58347. */
  58348. get isAttribute(): boolean;
  58349. set isAttribute(value: boolean);
  58350. /**
  58351. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58352. * Can only be set on exit points
  58353. */
  58354. get isVarying(): boolean;
  58355. set isVarying(value: boolean);
  58356. /**
  58357. * Gets a boolean indicating that the current connection point is a system value
  58358. */
  58359. get isSystemValue(): boolean;
  58360. /**
  58361. * Gets or sets the current well known value or null if not defined as a system value
  58362. */
  58363. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58364. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58365. /**
  58366. * Gets the current class name
  58367. * @returns the class name
  58368. */
  58369. getClassName(): string;
  58370. /**
  58371. * Animate the input if animationType !== None
  58372. * @param scene defines the rendering scene
  58373. */
  58374. animate(scene: Scene): void;
  58375. private _emitDefine;
  58376. initialize(state: NodeMaterialBuildState): void;
  58377. /**
  58378. * Set the input block to its default value (based on its type)
  58379. */
  58380. setDefaultValue(): void;
  58381. private _emitConstant;
  58382. private _emit;
  58383. /** @hidden */
  58384. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58385. /** @hidden */
  58386. _transmit(effect: Effect, scene: Scene): void;
  58387. protected _buildBlock(state: NodeMaterialBuildState): void;
  58388. protected _dumpPropertiesCode(): string;
  58389. dispose(): void;
  58390. serialize(): any;
  58391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58392. }
  58393. }
  58394. declare module BABYLON {
  58395. /**
  58396. * Enum used to define the compatibility state between two connection points
  58397. */
  58398. export enum NodeMaterialConnectionPointCompatibilityStates {
  58399. /** Points are compatibles */
  58400. Compatible = 0,
  58401. /** Points are incompatible because of their types */
  58402. TypeIncompatible = 1,
  58403. /** Points are incompatible because of their targets (vertex vs fragment) */
  58404. TargetIncompatible = 2
  58405. }
  58406. /**
  58407. * Defines the direction of a connection point
  58408. */
  58409. export enum NodeMaterialConnectionPointDirection {
  58410. /** Input */
  58411. Input = 0,
  58412. /** Output */
  58413. Output = 1
  58414. }
  58415. /**
  58416. * Defines a connection point for a block
  58417. */
  58418. export class NodeMaterialConnectionPoint {
  58419. /** @hidden */
  58420. _ownerBlock: NodeMaterialBlock;
  58421. /** @hidden */
  58422. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58423. private _endpoints;
  58424. private _associatedVariableName;
  58425. private _direction;
  58426. /** @hidden */
  58427. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58428. /** @hidden */
  58429. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58430. private _type;
  58431. /** @hidden */
  58432. _enforceAssociatedVariableName: boolean;
  58433. /** Gets the direction of the point */
  58434. get direction(): NodeMaterialConnectionPointDirection;
  58435. /**
  58436. * Gets or sets the additional types supported by this connection point
  58437. */
  58438. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58439. /**
  58440. * Gets or sets the additional types excluded by this connection point
  58441. */
  58442. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58443. /**
  58444. * Observable triggered when this point is connected
  58445. */
  58446. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58447. /**
  58448. * Gets or sets the associated variable name in the shader
  58449. */
  58450. get associatedVariableName(): string;
  58451. set associatedVariableName(value: string);
  58452. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58453. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58454. /**
  58455. * Gets or sets the connection point type (default is float)
  58456. */
  58457. get type(): NodeMaterialBlockConnectionPointTypes;
  58458. set type(value: NodeMaterialBlockConnectionPointTypes);
  58459. /**
  58460. * Gets or sets the connection point name
  58461. */
  58462. name: string;
  58463. /**
  58464. * Gets or sets a boolean indicating that this connection point can be omitted
  58465. */
  58466. isOptional: boolean;
  58467. /**
  58468. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58469. */
  58470. define: string;
  58471. /** @hidden */
  58472. _prioritizeVertex: boolean;
  58473. private _target;
  58474. /** Gets or sets the target of that connection point */
  58475. get target(): NodeMaterialBlockTargets;
  58476. set target(value: NodeMaterialBlockTargets);
  58477. /**
  58478. * Gets a boolean indicating that the current point is connected
  58479. */
  58480. get isConnected(): boolean;
  58481. /**
  58482. * Gets a boolean indicating that the current point is connected to an input block
  58483. */
  58484. get isConnectedToInputBlock(): boolean;
  58485. /**
  58486. * Gets a the connected input block (if any)
  58487. */
  58488. get connectInputBlock(): Nullable<InputBlock>;
  58489. /** Get the other side of the connection (if any) */
  58490. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58491. /** Get the block that owns this connection point */
  58492. get ownerBlock(): NodeMaterialBlock;
  58493. /** Get the block connected on the other side of this connection (if any) */
  58494. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58495. /** Get the block connected on the endpoints of this connection (if any) */
  58496. get connectedBlocks(): Array<NodeMaterialBlock>;
  58497. /** Gets the list of connected endpoints */
  58498. get endpoints(): NodeMaterialConnectionPoint[];
  58499. /** Gets a boolean indicating if that output point is connected to at least one input */
  58500. get hasEndpoints(): boolean;
  58501. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58502. get isConnectedInVertexShader(): boolean;
  58503. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58504. get isConnectedInFragmentShader(): boolean;
  58505. /**
  58506. * Creates a new connection point
  58507. * @param name defines the connection point name
  58508. * @param ownerBlock defines the block hosting this connection point
  58509. * @param direction defines the direction of the connection point
  58510. */
  58511. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58512. /**
  58513. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58514. * @returns the class name
  58515. */
  58516. getClassName(): string;
  58517. /**
  58518. * Gets a boolean indicating if the current point can be connected to another point
  58519. * @param connectionPoint defines the other connection point
  58520. * @returns a boolean
  58521. */
  58522. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58523. /**
  58524. * Gets a number indicating if the current point can be connected to another point
  58525. * @param connectionPoint defines the other connection point
  58526. * @returns a number defining the compatibility state
  58527. */
  58528. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58529. /**
  58530. * Connect this point to another connection point
  58531. * @param connectionPoint defines the other connection point
  58532. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58533. * @returns the current connection point
  58534. */
  58535. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58536. /**
  58537. * Disconnect this point from one of his endpoint
  58538. * @param endpoint defines the other connection point
  58539. * @returns the current connection point
  58540. */
  58541. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58542. /**
  58543. * Serializes this point in a JSON representation
  58544. * @returns the serialized point object
  58545. */
  58546. serialize(): any;
  58547. /**
  58548. * Release resources
  58549. */
  58550. dispose(): void;
  58551. }
  58552. }
  58553. declare module BABYLON {
  58554. /**
  58555. * Block used to add support for vertex skinning (bones)
  58556. */
  58557. export class BonesBlock extends NodeMaterialBlock {
  58558. /**
  58559. * Creates a new BonesBlock
  58560. * @param name defines the block name
  58561. */
  58562. constructor(name: string);
  58563. /**
  58564. * Initialize the block and prepare the context for build
  58565. * @param state defines the state that will be used for the build
  58566. */
  58567. initialize(state: NodeMaterialBuildState): void;
  58568. /**
  58569. * Gets the current class name
  58570. * @returns the class name
  58571. */
  58572. getClassName(): string;
  58573. /**
  58574. * Gets the matrix indices input component
  58575. */
  58576. get matricesIndices(): NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the matrix weights input component
  58579. */
  58580. get matricesWeights(): NodeMaterialConnectionPoint;
  58581. /**
  58582. * Gets the extra matrix indices input component
  58583. */
  58584. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58585. /**
  58586. * Gets the extra matrix weights input component
  58587. */
  58588. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58589. /**
  58590. * Gets the world input component
  58591. */
  58592. get world(): NodeMaterialConnectionPoint;
  58593. /**
  58594. * Gets the output component
  58595. */
  58596. get output(): NodeMaterialConnectionPoint;
  58597. autoConfigure(material: NodeMaterial): void;
  58598. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58601. protected _buildBlock(state: NodeMaterialBuildState): this;
  58602. }
  58603. }
  58604. declare module BABYLON {
  58605. /**
  58606. * Block used to add support for instances
  58607. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58608. */
  58609. export class InstancesBlock extends NodeMaterialBlock {
  58610. /**
  58611. * Creates a new InstancesBlock
  58612. * @param name defines the block name
  58613. */
  58614. constructor(name: string);
  58615. /**
  58616. * Gets the current class name
  58617. * @returns the class name
  58618. */
  58619. getClassName(): string;
  58620. /**
  58621. * Gets the first world row input component
  58622. */
  58623. get world0(): NodeMaterialConnectionPoint;
  58624. /**
  58625. * Gets the second world row input component
  58626. */
  58627. get world1(): NodeMaterialConnectionPoint;
  58628. /**
  58629. * Gets the third world row input component
  58630. */
  58631. get world2(): NodeMaterialConnectionPoint;
  58632. /**
  58633. * Gets the forth world row input component
  58634. */
  58635. get world3(): NodeMaterialConnectionPoint;
  58636. /**
  58637. * Gets the world input component
  58638. */
  58639. get world(): NodeMaterialConnectionPoint;
  58640. /**
  58641. * Gets the output component
  58642. */
  58643. get output(): NodeMaterialConnectionPoint;
  58644. /**
  58645. * Gets the isntanceID component
  58646. */
  58647. get instanceID(): NodeMaterialConnectionPoint;
  58648. autoConfigure(material: NodeMaterial): void;
  58649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58650. protected _buildBlock(state: NodeMaterialBuildState): this;
  58651. }
  58652. }
  58653. declare module BABYLON {
  58654. /**
  58655. * Block used to add morph targets support to vertex shader
  58656. */
  58657. export class MorphTargetsBlock extends NodeMaterialBlock {
  58658. private _repeatableContentAnchor;
  58659. /**
  58660. * Create a new MorphTargetsBlock
  58661. * @param name defines the block name
  58662. */
  58663. constructor(name: string);
  58664. /**
  58665. * Gets the current class name
  58666. * @returns the class name
  58667. */
  58668. getClassName(): string;
  58669. /**
  58670. * Gets the position input component
  58671. */
  58672. get position(): NodeMaterialConnectionPoint;
  58673. /**
  58674. * Gets the normal input component
  58675. */
  58676. get normal(): NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the tangent input component
  58679. */
  58680. get tangent(): NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the tangent input component
  58683. */
  58684. get uv(): NodeMaterialConnectionPoint;
  58685. /**
  58686. * Gets the position output component
  58687. */
  58688. get positionOutput(): NodeMaterialConnectionPoint;
  58689. /**
  58690. * Gets the normal output component
  58691. */
  58692. get normalOutput(): NodeMaterialConnectionPoint;
  58693. /**
  58694. * Gets the tangent output component
  58695. */
  58696. get tangentOutput(): NodeMaterialConnectionPoint;
  58697. /**
  58698. * Gets the tangent output component
  58699. */
  58700. get uvOutput(): NodeMaterialConnectionPoint;
  58701. initialize(state: NodeMaterialBuildState): void;
  58702. autoConfigure(material: NodeMaterial): void;
  58703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58705. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58706. protected _buildBlock(state: NodeMaterialBuildState): this;
  58707. }
  58708. }
  58709. declare module BABYLON {
  58710. /**
  58711. * Block used to get data information from a light
  58712. */
  58713. export class LightInformationBlock extends NodeMaterialBlock {
  58714. private _lightDataUniformName;
  58715. private _lightColorUniformName;
  58716. private _lightTypeDefineName;
  58717. /**
  58718. * Gets or sets the light associated with this block
  58719. */
  58720. light: Nullable<Light>;
  58721. /**
  58722. * Creates a new LightInformationBlock
  58723. * @param name defines the block name
  58724. */
  58725. constructor(name: string);
  58726. /**
  58727. * Gets the current class name
  58728. * @returns the class name
  58729. */
  58730. getClassName(): string;
  58731. /**
  58732. * Gets the world position input component
  58733. */
  58734. get worldPosition(): NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the direction output component
  58737. */
  58738. get direction(): NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the direction output component
  58741. */
  58742. get color(): NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the direction output component
  58745. */
  58746. get intensity(): NodeMaterialConnectionPoint;
  58747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58749. protected _buildBlock(state: NodeMaterialBuildState): this;
  58750. serialize(): any;
  58751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58752. }
  58753. }
  58754. declare module BABYLON {
  58755. /**
  58756. * Block used to add image processing support to fragment shader
  58757. */
  58758. export class ImageProcessingBlock extends NodeMaterialBlock {
  58759. /**
  58760. * Create a new ImageProcessingBlock
  58761. * @param name defines the block name
  58762. */
  58763. constructor(name: string);
  58764. /**
  58765. * Gets the current class name
  58766. * @returns the class name
  58767. */
  58768. getClassName(): string;
  58769. /**
  58770. * Gets the color input component
  58771. */
  58772. get color(): NodeMaterialConnectionPoint;
  58773. /**
  58774. * Gets the output component
  58775. */
  58776. get output(): NodeMaterialConnectionPoint;
  58777. /**
  58778. * Initialize the block and prepare the context for build
  58779. * @param state defines the state that will be used for the build
  58780. */
  58781. initialize(state: NodeMaterialBuildState): void;
  58782. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58784. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58785. protected _buildBlock(state: NodeMaterialBuildState): this;
  58786. }
  58787. }
  58788. declare module BABYLON {
  58789. /**
  58790. * Block used to pertub normals based on a normal map
  58791. */
  58792. export class PerturbNormalBlock extends NodeMaterialBlock {
  58793. private _tangentSpaceParameterName;
  58794. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58795. invertX: boolean;
  58796. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58797. invertY: boolean;
  58798. /**
  58799. * Create a new PerturbNormalBlock
  58800. * @param name defines the block name
  58801. */
  58802. constructor(name: string);
  58803. /**
  58804. * Gets the current class name
  58805. * @returns the class name
  58806. */
  58807. getClassName(): string;
  58808. /**
  58809. * Gets the world position input component
  58810. */
  58811. get worldPosition(): NodeMaterialConnectionPoint;
  58812. /**
  58813. * Gets the world normal input component
  58814. */
  58815. get worldNormal(): NodeMaterialConnectionPoint;
  58816. /**
  58817. * Gets the world tangent input component
  58818. */
  58819. get worldTangent(): NodeMaterialConnectionPoint;
  58820. /**
  58821. * Gets the uv input component
  58822. */
  58823. get uv(): NodeMaterialConnectionPoint;
  58824. /**
  58825. * Gets the normal map color input component
  58826. */
  58827. get normalMapColor(): NodeMaterialConnectionPoint;
  58828. /**
  58829. * Gets the strength input component
  58830. */
  58831. get strength(): NodeMaterialConnectionPoint;
  58832. /**
  58833. * Gets the output component
  58834. */
  58835. get output(): NodeMaterialConnectionPoint;
  58836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58838. autoConfigure(material: NodeMaterial): void;
  58839. protected _buildBlock(state: NodeMaterialBuildState): this;
  58840. protected _dumpPropertiesCode(): string;
  58841. serialize(): any;
  58842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58843. }
  58844. }
  58845. declare module BABYLON {
  58846. /**
  58847. * Block used to discard a pixel if a value is smaller than a cutoff
  58848. */
  58849. export class DiscardBlock extends NodeMaterialBlock {
  58850. /**
  58851. * Create a new DiscardBlock
  58852. * @param name defines the block name
  58853. */
  58854. constructor(name: string);
  58855. /**
  58856. * Gets the current class name
  58857. * @returns the class name
  58858. */
  58859. getClassName(): string;
  58860. /**
  58861. * Gets the color input component
  58862. */
  58863. get value(): NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the cutoff input component
  58866. */
  58867. get cutoff(): NodeMaterialConnectionPoint;
  58868. protected _buildBlock(state: NodeMaterialBuildState): this;
  58869. }
  58870. }
  58871. declare module BABYLON {
  58872. /**
  58873. * Block used to test if the fragment shader is front facing
  58874. */
  58875. export class FrontFacingBlock extends NodeMaterialBlock {
  58876. /**
  58877. * Creates a new FrontFacingBlock
  58878. * @param name defines the block name
  58879. */
  58880. constructor(name: string);
  58881. /**
  58882. * Gets the current class name
  58883. * @returns the class name
  58884. */
  58885. getClassName(): string;
  58886. /**
  58887. * Gets the output component
  58888. */
  58889. get output(): NodeMaterialConnectionPoint;
  58890. protected _buildBlock(state: NodeMaterialBuildState): this;
  58891. }
  58892. }
  58893. declare module BABYLON {
  58894. /**
  58895. * Block used to get the derivative value on x and y of a given input
  58896. */
  58897. export class DerivativeBlock extends NodeMaterialBlock {
  58898. /**
  58899. * Create a new DerivativeBlock
  58900. * @param name defines the block name
  58901. */
  58902. constructor(name: string);
  58903. /**
  58904. * Gets the current class name
  58905. * @returns the class name
  58906. */
  58907. getClassName(): string;
  58908. /**
  58909. * Gets the input component
  58910. */
  58911. get input(): NodeMaterialConnectionPoint;
  58912. /**
  58913. * Gets the derivative output on x
  58914. */
  58915. get dx(): NodeMaterialConnectionPoint;
  58916. /**
  58917. * Gets the derivative output on y
  58918. */
  58919. get dy(): NodeMaterialConnectionPoint;
  58920. protected _buildBlock(state: NodeMaterialBuildState): this;
  58921. }
  58922. }
  58923. declare module BABYLON {
  58924. /**
  58925. * Block used to add support for scene fog
  58926. */
  58927. export class FogBlock extends NodeMaterialBlock {
  58928. private _fogDistanceName;
  58929. private _fogParameters;
  58930. /**
  58931. * Create a new FogBlock
  58932. * @param name defines the block name
  58933. */
  58934. constructor(name: string);
  58935. /**
  58936. * Gets the current class name
  58937. * @returns the class name
  58938. */
  58939. getClassName(): string;
  58940. /**
  58941. * Gets the world position input component
  58942. */
  58943. get worldPosition(): NodeMaterialConnectionPoint;
  58944. /**
  58945. * Gets the view input component
  58946. */
  58947. get view(): NodeMaterialConnectionPoint;
  58948. /**
  58949. * Gets the color input component
  58950. */
  58951. get input(): NodeMaterialConnectionPoint;
  58952. /**
  58953. * Gets the fog color input component
  58954. */
  58955. get fogColor(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the output component
  58958. */
  58959. get output(): NodeMaterialConnectionPoint;
  58960. autoConfigure(material: NodeMaterial): void;
  58961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58963. protected _buildBlock(state: NodeMaterialBuildState): this;
  58964. }
  58965. }
  58966. declare module BABYLON {
  58967. /**
  58968. * Block used to add light in the fragment shader
  58969. */
  58970. export class LightBlock extends NodeMaterialBlock {
  58971. private _lightId;
  58972. /**
  58973. * Gets or sets the light associated with this block
  58974. */
  58975. light: Nullable<Light>;
  58976. /**
  58977. * Create a new LightBlock
  58978. * @param name defines the block name
  58979. */
  58980. constructor(name: string);
  58981. /**
  58982. * Gets the current class name
  58983. * @returns the class name
  58984. */
  58985. getClassName(): string;
  58986. /**
  58987. * Gets the world position input component
  58988. */
  58989. get worldPosition(): NodeMaterialConnectionPoint;
  58990. /**
  58991. * Gets the world normal input component
  58992. */
  58993. get worldNormal(): NodeMaterialConnectionPoint;
  58994. /**
  58995. * Gets the camera (or eye) position component
  58996. */
  58997. get cameraPosition(): NodeMaterialConnectionPoint;
  58998. /**
  58999. * Gets the glossiness component
  59000. */
  59001. get glossiness(): NodeMaterialConnectionPoint;
  59002. /**
  59003. * Gets the glossinness power component
  59004. */
  59005. get glossPower(): NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the diffuse color component
  59008. */
  59009. get diffuseColor(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the specular color component
  59012. */
  59013. get specularColor(): NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the diffuse output component
  59016. */
  59017. get diffuseOutput(): NodeMaterialConnectionPoint;
  59018. /**
  59019. * Gets the specular output component
  59020. */
  59021. get specularOutput(): NodeMaterialConnectionPoint;
  59022. /**
  59023. * Gets the shadow output component
  59024. */
  59025. get shadow(): NodeMaterialConnectionPoint;
  59026. autoConfigure(material: NodeMaterial): void;
  59027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59028. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59029. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59030. private _injectVertexCode;
  59031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59032. serialize(): any;
  59033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59034. }
  59035. }
  59036. declare module BABYLON {
  59037. /**
  59038. * Block used to multiply 2 values
  59039. */
  59040. export class MultiplyBlock extends NodeMaterialBlock {
  59041. /**
  59042. * Creates a new MultiplyBlock
  59043. * @param name defines the block name
  59044. */
  59045. constructor(name: string);
  59046. /**
  59047. * Gets the current class name
  59048. * @returns the class name
  59049. */
  59050. getClassName(): string;
  59051. /**
  59052. * Gets the left operand input component
  59053. */
  59054. get left(): NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the right operand input component
  59057. */
  59058. get right(): NodeMaterialConnectionPoint;
  59059. /**
  59060. * Gets the output component
  59061. */
  59062. get output(): NodeMaterialConnectionPoint;
  59063. protected _buildBlock(state: NodeMaterialBuildState): this;
  59064. }
  59065. }
  59066. declare module BABYLON {
  59067. /**
  59068. * Block used to add 2 vectors
  59069. */
  59070. export class AddBlock extends NodeMaterialBlock {
  59071. /**
  59072. * Creates a new AddBlock
  59073. * @param name defines the block name
  59074. */
  59075. constructor(name: string);
  59076. /**
  59077. * Gets the current class name
  59078. * @returns the class name
  59079. */
  59080. getClassName(): string;
  59081. /**
  59082. * Gets the left operand input component
  59083. */
  59084. get left(): NodeMaterialConnectionPoint;
  59085. /**
  59086. * Gets the right operand input component
  59087. */
  59088. get right(): NodeMaterialConnectionPoint;
  59089. /**
  59090. * Gets the output component
  59091. */
  59092. get output(): NodeMaterialConnectionPoint;
  59093. protected _buildBlock(state: NodeMaterialBuildState): this;
  59094. }
  59095. }
  59096. declare module BABYLON {
  59097. /**
  59098. * Block used to scale a vector by a float
  59099. */
  59100. export class ScaleBlock extends NodeMaterialBlock {
  59101. /**
  59102. * Creates a new ScaleBlock
  59103. * @param name defines the block name
  59104. */
  59105. constructor(name: string);
  59106. /**
  59107. * Gets the current class name
  59108. * @returns the class name
  59109. */
  59110. getClassName(): string;
  59111. /**
  59112. * Gets the input component
  59113. */
  59114. get input(): NodeMaterialConnectionPoint;
  59115. /**
  59116. * Gets the factor input component
  59117. */
  59118. get factor(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the output component
  59121. */
  59122. get output(): NodeMaterialConnectionPoint;
  59123. protected _buildBlock(state: NodeMaterialBuildState): this;
  59124. }
  59125. }
  59126. declare module BABYLON {
  59127. /**
  59128. * Block used to clamp a float
  59129. */
  59130. export class ClampBlock extends NodeMaterialBlock {
  59131. /** Gets or sets the minimum range */
  59132. minimum: number;
  59133. /** Gets or sets the maximum range */
  59134. maximum: number;
  59135. /**
  59136. * Creates a new ClampBlock
  59137. * @param name defines the block name
  59138. */
  59139. constructor(name: string);
  59140. /**
  59141. * Gets the current class name
  59142. * @returns the class name
  59143. */
  59144. getClassName(): string;
  59145. /**
  59146. * Gets the value input component
  59147. */
  59148. get value(): NodeMaterialConnectionPoint;
  59149. /**
  59150. * Gets the output component
  59151. */
  59152. get output(): NodeMaterialConnectionPoint;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this;
  59154. protected _dumpPropertiesCode(): string;
  59155. serialize(): any;
  59156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59157. }
  59158. }
  59159. declare module BABYLON {
  59160. /**
  59161. * Block used to apply a cross product between 2 vectors
  59162. */
  59163. export class CrossBlock extends NodeMaterialBlock {
  59164. /**
  59165. * Creates a new CrossBlock
  59166. * @param name defines the block name
  59167. */
  59168. constructor(name: string);
  59169. /**
  59170. * Gets the current class name
  59171. * @returns the class name
  59172. */
  59173. getClassName(): string;
  59174. /**
  59175. * Gets the left operand input component
  59176. */
  59177. get left(): NodeMaterialConnectionPoint;
  59178. /**
  59179. * Gets the right operand input component
  59180. */
  59181. get right(): NodeMaterialConnectionPoint;
  59182. /**
  59183. * Gets the output component
  59184. */
  59185. get output(): NodeMaterialConnectionPoint;
  59186. protected _buildBlock(state: NodeMaterialBuildState): this;
  59187. }
  59188. }
  59189. declare module BABYLON {
  59190. /**
  59191. * Block used to apply a dot product between 2 vectors
  59192. */
  59193. export class DotBlock extends NodeMaterialBlock {
  59194. /**
  59195. * Creates a new DotBlock
  59196. * @param name defines the block name
  59197. */
  59198. constructor(name: string);
  59199. /**
  59200. * Gets the current class name
  59201. * @returns the class name
  59202. */
  59203. getClassName(): string;
  59204. /**
  59205. * Gets the left operand input component
  59206. */
  59207. get left(): NodeMaterialConnectionPoint;
  59208. /**
  59209. * Gets the right operand input component
  59210. */
  59211. get right(): NodeMaterialConnectionPoint;
  59212. /**
  59213. * Gets the output component
  59214. */
  59215. get output(): NodeMaterialConnectionPoint;
  59216. protected _buildBlock(state: NodeMaterialBuildState): this;
  59217. }
  59218. }
  59219. declare module BABYLON {
  59220. /**
  59221. * Block used to remap a float from a range to a new one
  59222. */
  59223. export class RemapBlock extends NodeMaterialBlock {
  59224. /**
  59225. * Gets or sets the source range
  59226. */
  59227. sourceRange: Vector2;
  59228. /**
  59229. * Gets or sets the target range
  59230. */
  59231. targetRange: Vector2;
  59232. /**
  59233. * Creates a new RemapBlock
  59234. * @param name defines the block name
  59235. */
  59236. constructor(name: string);
  59237. /**
  59238. * Gets the current class name
  59239. * @returns the class name
  59240. */
  59241. getClassName(): string;
  59242. /**
  59243. * Gets the input component
  59244. */
  59245. get input(): NodeMaterialConnectionPoint;
  59246. /**
  59247. * Gets the source min input component
  59248. */
  59249. get sourceMin(): NodeMaterialConnectionPoint;
  59250. /**
  59251. * Gets the source max input component
  59252. */
  59253. get sourceMax(): NodeMaterialConnectionPoint;
  59254. /**
  59255. * Gets the target min input component
  59256. */
  59257. get targetMin(): NodeMaterialConnectionPoint;
  59258. /**
  59259. * Gets the target max input component
  59260. */
  59261. get targetMax(): NodeMaterialConnectionPoint;
  59262. /**
  59263. * Gets the output component
  59264. */
  59265. get output(): NodeMaterialConnectionPoint;
  59266. protected _buildBlock(state: NodeMaterialBuildState): this;
  59267. protected _dumpPropertiesCode(): string;
  59268. serialize(): any;
  59269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59270. }
  59271. }
  59272. declare module BABYLON {
  59273. /**
  59274. * Block used to normalize a vector
  59275. */
  59276. export class NormalizeBlock extends NodeMaterialBlock {
  59277. /**
  59278. * Creates a new NormalizeBlock
  59279. * @param name defines the block name
  59280. */
  59281. constructor(name: string);
  59282. /**
  59283. * Gets the current class name
  59284. * @returns the class name
  59285. */
  59286. getClassName(): string;
  59287. /**
  59288. * Gets the input component
  59289. */
  59290. get input(): NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the output component
  59293. */
  59294. get output(): NodeMaterialConnectionPoint;
  59295. protected _buildBlock(state: NodeMaterialBuildState): this;
  59296. }
  59297. }
  59298. declare module BABYLON {
  59299. /**
  59300. * Operations supported by the Trigonometry block
  59301. */
  59302. export enum TrigonometryBlockOperations {
  59303. /** Cos */
  59304. Cos = 0,
  59305. /** Sin */
  59306. Sin = 1,
  59307. /** Abs */
  59308. Abs = 2,
  59309. /** Exp */
  59310. Exp = 3,
  59311. /** Exp2 */
  59312. Exp2 = 4,
  59313. /** Round */
  59314. Round = 5,
  59315. /** Floor */
  59316. Floor = 6,
  59317. /** Ceiling */
  59318. Ceiling = 7,
  59319. /** Square root */
  59320. Sqrt = 8,
  59321. /** Log */
  59322. Log = 9,
  59323. /** Tangent */
  59324. Tan = 10,
  59325. /** Arc tangent */
  59326. ArcTan = 11,
  59327. /** Arc cosinus */
  59328. ArcCos = 12,
  59329. /** Arc sinus */
  59330. ArcSin = 13,
  59331. /** Fraction */
  59332. Fract = 14,
  59333. /** Sign */
  59334. Sign = 15,
  59335. /** To radians (from degrees) */
  59336. Radians = 16,
  59337. /** To degrees (from radians) */
  59338. Degrees = 17
  59339. }
  59340. /**
  59341. * Block used to apply trigonometry operation to floats
  59342. */
  59343. export class TrigonometryBlock extends NodeMaterialBlock {
  59344. /**
  59345. * Gets or sets the operation applied by the block
  59346. */
  59347. operation: TrigonometryBlockOperations;
  59348. /**
  59349. * Creates a new TrigonometryBlock
  59350. * @param name defines the block name
  59351. */
  59352. constructor(name: string);
  59353. /**
  59354. * Gets the current class name
  59355. * @returns the class name
  59356. */
  59357. getClassName(): string;
  59358. /**
  59359. * Gets the input component
  59360. */
  59361. get input(): NodeMaterialConnectionPoint;
  59362. /**
  59363. * Gets the output component
  59364. */
  59365. get output(): NodeMaterialConnectionPoint;
  59366. protected _buildBlock(state: NodeMaterialBuildState): this;
  59367. serialize(): any;
  59368. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59369. protected _dumpPropertiesCode(): string;
  59370. }
  59371. }
  59372. declare module BABYLON {
  59373. /**
  59374. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59375. */
  59376. export class ColorMergerBlock extends NodeMaterialBlock {
  59377. /**
  59378. * Create a new ColorMergerBlock
  59379. * @param name defines the block name
  59380. */
  59381. constructor(name: string);
  59382. /**
  59383. * Gets the current class name
  59384. * @returns the class name
  59385. */
  59386. getClassName(): string;
  59387. /**
  59388. * Gets the rgb component (input)
  59389. */
  59390. get rgbIn(): NodeMaterialConnectionPoint;
  59391. /**
  59392. * Gets the r component (input)
  59393. */
  59394. get r(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the g component (input)
  59397. */
  59398. get g(): NodeMaterialConnectionPoint;
  59399. /**
  59400. * Gets the b component (input)
  59401. */
  59402. get b(): NodeMaterialConnectionPoint;
  59403. /**
  59404. * Gets the a component (input)
  59405. */
  59406. get a(): NodeMaterialConnectionPoint;
  59407. /**
  59408. * Gets the rgba component (output)
  59409. */
  59410. get rgba(): NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the rgb component (output)
  59413. */
  59414. get rgbOut(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the rgb component (output)
  59417. * @deprecated Please use rgbOut instead.
  59418. */
  59419. get rgb(): NodeMaterialConnectionPoint;
  59420. protected _buildBlock(state: NodeMaterialBuildState): this;
  59421. }
  59422. }
  59423. declare module BABYLON {
  59424. /**
  59425. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59426. */
  59427. export class VectorMergerBlock extends NodeMaterialBlock {
  59428. /**
  59429. * Create a new VectorMergerBlock
  59430. * @param name defines the block name
  59431. */
  59432. constructor(name: string);
  59433. /**
  59434. * Gets the current class name
  59435. * @returns the class name
  59436. */
  59437. getClassName(): string;
  59438. /**
  59439. * Gets the xyz component (input)
  59440. */
  59441. get xyzIn(): NodeMaterialConnectionPoint;
  59442. /**
  59443. * Gets the xy component (input)
  59444. */
  59445. get xyIn(): NodeMaterialConnectionPoint;
  59446. /**
  59447. * Gets the x component (input)
  59448. */
  59449. get x(): NodeMaterialConnectionPoint;
  59450. /**
  59451. * Gets the y component (input)
  59452. */
  59453. get y(): NodeMaterialConnectionPoint;
  59454. /**
  59455. * Gets the z component (input)
  59456. */
  59457. get z(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the w component (input)
  59460. */
  59461. get w(): NodeMaterialConnectionPoint;
  59462. /**
  59463. * Gets the xyzw component (output)
  59464. */
  59465. get xyzw(): NodeMaterialConnectionPoint;
  59466. /**
  59467. * Gets the xyz component (output)
  59468. */
  59469. get xyzOut(): NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the xy component (output)
  59472. */
  59473. get xyOut(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the xy component (output)
  59476. * @deprecated Please use xyOut instead.
  59477. */
  59478. get xy(): NodeMaterialConnectionPoint;
  59479. /**
  59480. * Gets the xyz component (output)
  59481. * @deprecated Please use xyzOut instead.
  59482. */
  59483. get xyz(): NodeMaterialConnectionPoint;
  59484. protected _buildBlock(state: NodeMaterialBuildState): this;
  59485. }
  59486. }
  59487. declare module BABYLON {
  59488. /**
  59489. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59490. */
  59491. export class ColorSplitterBlock extends NodeMaterialBlock {
  59492. /**
  59493. * Create a new ColorSplitterBlock
  59494. * @param name defines the block name
  59495. */
  59496. constructor(name: string);
  59497. /**
  59498. * Gets the current class name
  59499. * @returns the class name
  59500. */
  59501. getClassName(): string;
  59502. /**
  59503. * Gets the rgba component (input)
  59504. */
  59505. get rgba(): NodeMaterialConnectionPoint;
  59506. /**
  59507. * Gets the rgb component (input)
  59508. */
  59509. get rgbIn(): NodeMaterialConnectionPoint;
  59510. /**
  59511. * Gets the rgb component (output)
  59512. */
  59513. get rgbOut(): NodeMaterialConnectionPoint;
  59514. /**
  59515. * Gets the r component (output)
  59516. */
  59517. get r(): NodeMaterialConnectionPoint;
  59518. /**
  59519. * Gets the g component (output)
  59520. */
  59521. get g(): NodeMaterialConnectionPoint;
  59522. /**
  59523. * Gets the b component (output)
  59524. */
  59525. get b(): NodeMaterialConnectionPoint;
  59526. /**
  59527. * Gets the a component (output)
  59528. */
  59529. get a(): NodeMaterialConnectionPoint;
  59530. protected _inputRename(name: string): string;
  59531. protected _outputRename(name: string): string;
  59532. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59533. }
  59534. }
  59535. declare module BABYLON {
  59536. /**
  59537. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59538. */
  59539. export class VectorSplitterBlock extends NodeMaterialBlock {
  59540. /**
  59541. * Create a new VectorSplitterBlock
  59542. * @param name defines the block name
  59543. */
  59544. constructor(name: string);
  59545. /**
  59546. * Gets the current class name
  59547. * @returns the class name
  59548. */
  59549. getClassName(): string;
  59550. /**
  59551. * Gets the xyzw component (input)
  59552. */
  59553. get xyzw(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the xyz component (input)
  59556. */
  59557. get xyzIn(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the xy component (input)
  59560. */
  59561. get xyIn(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the xyz component (output)
  59564. */
  59565. get xyzOut(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the xy component (output)
  59568. */
  59569. get xyOut(): NodeMaterialConnectionPoint;
  59570. /**
  59571. * Gets the x component (output)
  59572. */
  59573. get x(): NodeMaterialConnectionPoint;
  59574. /**
  59575. * Gets the y component (output)
  59576. */
  59577. get y(): NodeMaterialConnectionPoint;
  59578. /**
  59579. * Gets the z component (output)
  59580. */
  59581. get z(): NodeMaterialConnectionPoint;
  59582. /**
  59583. * Gets the w component (output)
  59584. */
  59585. get w(): NodeMaterialConnectionPoint;
  59586. protected _inputRename(name: string): string;
  59587. protected _outputRename(name: string): string;
  59588. protected _buildBlock(state: NodeMaterialBuildState): this;
  59589. }
  59590. }
  59591. declare module BABYLON {
  59592. /**
  59593. * Block used to lerp between 2 values
  59594. */
  59595. export class LerpBlock extends NodeMaterialBlock {
  59596. /**
  59597. * Creates a new LerpBlock
  59598. * @param name defines the block name
  59599. */
  59600. constructor(name: string);
  59601. /**
  59602. * Gets the current class name
  59603. * @returns the class name
  59604. */
  59605. getClassName(): string;
  59606. /**
  59607. * Gets the left operand input component
  59608. */
  59609. get left(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the right operand input component
  59612. */
  59613. get right(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the gradient operand input component
  59616. */
  59617. get gradient(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the output component
  59620. */
  59621. get output(): NodeMaterialConnectionPoint;
  59622. protected _buildBlock(state: NodeMaterialBuildState): this;
  59623. }
  59624. }
  59625. declare module BABYLON {
  59626. /**
  59627. * Block used to divide 2 vectors
  59628. */
  59629. export class DivideBlock extends NodeMaterialBlock {
  59630. /**
  59631. * Creates a new DivideBlock
  59632. * @param name defines the block name
  59633. */
  59634. constructor(name: string);
  59635. /**
  59636. * Gets the current class name
  59637. * @returns the class name
  59638. */
  59639. getClassName(): string;
  59640. /**
  59641. * Gets the left operand input component
  59642. */
  59643. get left(): NodeMaterialConnectionPoint;
  59644. /**
  59645. * Gets the right operand input component
  59646. */
  59647. get right(): NodeMaterialConnectionPoint;
  59648. /**
  59649. * Gets the output component
  59650. */
  59651. get output(): NodeMaterialConnectionPoint;
  59652. protected _buildBlock(state: NodeMaterialBuildState): this;
  59653. }
  59654. }
  59655. declare module BABYLON {
  59656. /**
  59657. * Block used to subtract 2 vectors
  59658. */
  59659. export class SubtractBlock extends NodeMaterialBlock {
  59660. /**
  59661. * Creates a new SubtractBlock
  59662. * @param name defines the block name
  59663. */
  59664. constructor(name: string);
  59665. /**
  59666. * Gets the current class name
  59667. * @returns the class name
  59668. */
  59669. getClassName(): string;
  59670. /**
  59671. * Gets the left operand input component
  59672. */
  59673. get left(): NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the right operand input component
  59676. */
  59677. get right(): NodeMaterialConnectionPoint;
  59678. /**
  59679. * Gets the output component
  59680. */
  59681. get output(): NodeMaterialConnectionPoint;
  59682. protected _buildBlock(state: NodeMaterialBuildState): this;
  59683. }
  59684. }
  59685. declare module BABYLON {
  59686. /**
  59687. * Block used to step a value
  59688. */
  59689. export class StepBlock extends NodeMaterialBlock {
  59690. /**
  59691. * Creates a new StepBlock
  59692. * @param name defines the block name
  59693. */
  59694. constructor(name: string);
  59695. /**
  59696. * Gets the current class name
  59697. * @returns the class name
  59698. */
  59699. getClassName(): string;
  59700. /**
  59701. * Gets the value operand input component
  59702. */
  59703. get value(): NodeMaterialConnectionPoint;
  59704. /**
  59705. * Gets the edge operand input component
  59706. */
  59707. get edge(): NodeMaterialConnectionPoint;
  59708. /**
  59709. * Gets the output component
  59710. */
  59711. get output(): NodeMaterialConnectionPoint;
  59712. protected _buildBlock(state: NodeMaterialBuildState): this;
  59713. }
  59714. }
  59715. declare module BABYLON {
  59716. /**
  59717. * Block used to get the opposite (1 - x) of a value
  59718. */
  59719. export class OneMinusBlock extends NodeMaterialBlock {
  59720. /**
  59721. * Creates a new OneMinusBlock
  59722. * @param name defines the block name
  59723. */
  59724. constructor(name: string);
  59725. /**
  59726. * Gets the current class name
  59727. * @returns the class name
  59728. */
  59729. getClassName(): string;
  59730. /**
  59731. * Gets the input component
  59732. */
  59733. get input(): NodeMaterialConnectionPoint;
  59734. /**
  59735. * Gets the output component
  59736. */
  59737. get output(): NodeMaterialConnectionPoint;
  59738. protected _buildBlock(state: NodeMaterialBuildState): this;
  59739. }
  59740. }
  59741. declare module BABYLON {
  59742. /**
  59743. * Block used to get the view direction
  59744. */
  59745. export class ViewDirectionBlock extends NodeMaterialBlock {
  59746. /**
  59747. * Creates a new ViewDirectionBlock
  59748. * @param name defines the block name
  59749. */
  59750. constructor(name: string);
  59751. /**
  59752. * Gets the current class name
  59753. * @returns the class name
  59754. */
  59755. getClassName(): string;
  59756. /**
  59757. * Gets the world position component
  59758. */
  59759. get worldPosition(): NodeMaterialConnectionPoint;
  59760. /**
  59761. * Gets the camera position component
  59762. */
  59763. get cameraPosition(): NodeMaterialConnectionPoint;
  59764. /**
  59765. * Gets the output component
  59766. */
  59767. get output(): NodeMaterialConnectionPoint;
  59768. autoConfigure(material: NodeMaterial): void;
  59769. protected _buildBlock(state: NodeMaterialBuildState): this;
  59770. }
  59771. }
  59772. declare module BABYLON {
  59773. /**
  59774. * Block used to compute fresnel value
  59775. */
  59776. export class FresnelBlock extends NodeMaterialBlock {
  59777. /**
  59778. * Create a new FresnelBlock
  59779. * @param name defines the block name
  59780. */
  59781. constructor(name: string);
  59782. /**
  59783. * Gets the current class name
  59784. * @returns the class name
  59785. */
  59786. getClassName(): string;
  59787. /**
  59788. * Gets the world normal input component
  59789. */
  59790. get worldNormal(): NodeMaterialConnectionPoint;
  59791. /**
  59792. * Gets the view direction input component
  59793. */
  59794. get viewDirection(): NodeMaterialConnectionPoint;
  59795. /**
  59796. * Gets the bias input component
  59797. */
  59798. get bias(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the camera (or eye) position component
  59801. */
  59802. get power(): NodeMaterialConnectionPoint;
  59803. /**
  59804. * Gets the fresnel output component
  59805. */
  59806. get fresnel(): NodeMaterialConnectionPoint;
  59807. autoConfigure(material: NodeMaterial): void;
  59808. protected _buildBlock(state: NodeMaterialBuildState): this;
  59809. }
  59810. }
  59811. declare module BABYLON {
  59812. /**
  59813. * Block used to get the max of 2 values
  59814. */
  59815. export class MaxBlock extends NodeMaterialBlock {
  59816. /**
  59817. * Creates a new MaxBlock
  59818. * @param name defines the block name
  59819. */
  59820. constructor(name: string);
  59821. /**
  59822. * Gets the current class name
  59823. * @returns the class name
  59824. */
  59825. getClassName(): string;
  59826. /**
  59827. * Gets the left operand input component
  59828. */
  59829. get left(): NodeMaterialConnectionPoint;
  59830. /**
  59831. * Gets the right operand input component
  59832. */
  59833. get right(): NodeMaterialConnectionPoint;
  59834. /**
  59835. * Gets the output component
  59836. */
  59837. get output(): NodeMaterialConnectionPoint;
  59838. protected _buildBlock(state: NodeMaterialBuildState): this;
  59839. }
  59840. }
  59841. declare module BABYLON {
  59842. /**
  59843. * Block used to get the min of 2 values
  59844. */
  59845. export class MinBlock extends NodeMaterialBlock {
  59846. /**
  59847. * Creates a new MinBlock
  59848. * @param name defines the block name
  59849. */
  59850. constructor(name: string);
  59851. /**
  59852. * Gets the current class name
  59853. * @returns the class name
  59854. */
  59855. getClassName(): string;
  59856. /**
  59857. * Gets the left operand input component
  59858. */
  59859. get left(): NodeMaterialConnectionPoint;
  59860. /**
  59861. * Gets the right operand input component
  59862. */
  59863. get right(): NodeMaterialConnectionPoint;
  59864. /**
  59865. * Gets the output component
  59866. */
  59867. get output(): NodeMaterialConnectionPoint;
  59868. protected _buildBlock(state: NodeMaterialBuildState): this;
  59869. }
  59870. }
  59871. declare module BABYLON {
  59872. /**
  59873. * Block used to get the distance between 2 values
  59874. */
  59875. export class DistanceBlock extends NodeMaterialBlock {
  59876. /**
  59877. * Creates a new DistanceBlock
  59878. * @param name defines the block name
  59879. */
  59880. constructor(name: string);
  59881. /**
  59882. * Gets the current class name
  59883. * @returns the class name
  59884. */
  59885. getClassName(): string;
  59886. /**
  59887. * Gets the left operand input component
  59888. */
  59889. get left(): NodeMaterialConnectionPoint;
  59890. /**
  59891. * Gets the right operand input component
  59892. */
  59893. get right(): NodeMaterialConnectionPoint;
  59894. /**
  59895. * Gets the output component
  59896. */
  59897. get output(): NodeMaterialConnectionPoint;
  59898. protected _buildBlock(state: NodeMaterialBuildState): this;
  59899. }
  59900. }
  59901. declare module BABYLON {
  59902. /**
  59903. * Block used to get the length of a vector
  59904. */
  59905. export class LengthBlock extends NodeMaterialBlock {
  59906. /**
  59907. * Creates a new LengthBlock
  59908. * @param name defines the block name
  59909. */
  59910. constructor(name: string);
  59911. /**
  59912. * Gets the current class name
  59913. * @returns the class name
  59914. */
  59915. getClassName(): string;
  59916. /**
  59917. * Gets the value input component
  59918. */
  59919. get value(): NodeMaterialConnectionPoint;
  59920. /**
  59921. * Gets the output component
  59922. */
  59923. get output(): NodeMaterialConnectionPoint;
  59924. protected _buildBlock(state: NodeMaterialBuildState): this;
  59925. }
  59926. }
  59927. declare module BABYLON {
  59928. /**
  59929. * Block used to get negative version of a value (i.e. x * -1)
  59930. */
  59931. export class NegateBlock extends NodeMaterialBlock {
  59932. /**
  59933. * Creates a new NegateBlock
  59934. * @param name defines the block name
  59935. */
  59936. constructor(name: string);
  59937. /**
  59938. * Gets the current class name
  59939. * @returns the class name
  59940. */
  59941. getClassName(): string;
  59942. /**
  59943. * Gets the value input component
  59944. */
  59945. get value(): NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the output component
  59948. */
  59949. get output(): NodeMaterialConnectionPoint;
  59950. protected _buildBlock(state: NodeMaterialBuildState): this;
  59951. }
  59952. }
  59953. declare module BABYLON {
  59954. /**
  59955. * Block used to get the value of the first parameter raised to the power of the second
  59956. */
  59957. export class PowBlock extends NodeMaterialBlock {
  59958. /**
  59959. * Creates a new PowBlock
  59960. * @param name defines the block name
  59961. */
  59962. constructor(name: string);
  59963. /**
  59964. * Gets the current class name
  59965. * @returns the class name
  59966. */
  59967. getClassName(): string;
  59968. /**
  59969. * Gets the value operand input component
  59970. */
  59971. get value(): NodeMaterialConnectionPoint;
  59972. /**
  59973. * Gets the power operand input component
  59974. */
  59975. get power(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the output component
  59978. */
  59979. get output(): NodeMaterialConnectionPoint;
  59980. protected _buildBlock(state: NodeMaterialBuildState): this;
  59981. }
  59982. }
  59983. declare module BABYLON {
  59984. /**
  59985. * Block used to get a random number
  59986. */
  59987. export class RandomNumberBlock extends NodeMaterialBlock {
  59988. /**
  59989. * Creates a new RandomNumberBlock
  59990. * @param name defines the block name
  59991. */
  59992. constructor(name: string);
  59993. /**
  59994. * Gets the current class name
  59995. * @returns the class name
  59996. */
  59997. getClassName(): string;
  59998. /**
  59999. * Gets the seed input component
  60000. */
  60001. get seed(): NodeMaterialConnectionPoint;
  60002. /**
  60003. * Gets the output component
  60004. */
  60005. get output(): NodeMaterialConnectionPoint;
  60006. protected _buildBlock(state: NodeMaterialBuildState): this;
  60007. }
  60008. }
  60009. declare module BABYLON {
  60010. /**
  60011. * Block used to compute arc tangent of 2 values
  60012. */
  60013. export class ArcTan2Block extends NodeMaterialBlock {
  60014. /**
  60015. * Creates a new ArcTan2Block
  60016. * @param name defines the block name
  60017. */
  60018. constructor(name: string);
  60019. /**
  60020. * Gets the current class name
  60021. * @returns the class name
  60022. */
  60023. getClassName(): string;
  60024. /**
  60025. * Gets the x operand input component
  60026. */
  60027. get x(): NodeMaterialConnectionPoint;
  60028. /**
  60029. * Gets the y operand input component
  60030. */
  60031. get y(): NodeMaterialConnectionPoint;
  60032. /**
  60033. * Gets the output component
  60034. */
  60035. get output(): NodeMaterialConnectionPoint;
  60036. protected _buildBlock(state: NodeMaterialBuildState): this;
  60037. }
  60038. }
  60039. declare module BABYLON {
  60040. /**
  60041. * Block used to smooth step a value
  60042. */
  60043. export class SmoothStepBlock extends NodeMaterialBlock {
  60044. /**
  60045. * Creates a new SmoothStepBlock
  60046. * @param name defines the block name
  60047. */
  60048. constructor(name: string);
  60049. /**
  60050. * Gets the current class name
  60051. * @returns the class name
  60052. */
  60053. getClassName(): string;
  60054. /**
  60055. * Gets the value operand input component
  60056. */
  60057. get value(): NodeMaterialConnectionPoint;
  60058. /**
  60059. * Gets the first edge operand input component
  60060. */
  60061. get edge0(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the second edge operand input component
  60064. */
  60065. get edge1(): NodeMaterialConnectionPoint;
  60066. /**
  60067. * Gets the output component
  60068. */
  60069. get output(): NodeMaterialConnectionPoint;
  60070. protected _buildBlock(state: NodeMaterialBuildState): this;
  60071. }
  60072. }
  60073. declare module BABYLON {
  60074. /**
  60075. * Block used to get the reciprocal (1 / x) of a value
  60076. */
  60077. export class ReciprocalBlock extends NodeMaterialBlock {
  60078. /**
  60079. * Creates a new ReciprocalBlock
  60080. * @param name defines the block name
  60081. */
  60082. constructor(name: string);
  60083. /**
  60084. * Gets the current class name
  60085. * @returns the class name
  60086. */
  60087. getClassName(): string;
  60088. /**
  60089. * Gets the input component
  60090. */
  60091. get input(): NodeMaterialConnectionPoint;
  60092. /**
  60093. * Gets the output component
  60094. */
  60095. get output(): NodeMaterialConnectionPoint;
  60096. protected _buildBlock(state: NodeMaterialBuildState): this;
  60097. }
  60098. }
  60099. declare module BABYLON {
  60100. /**
  60101. * Block used to replace a color by another one
  60102. */
  60103. export class ReplaceColorBlock extends NodeMaterialBlock {
  60104. /**
  60105. * Creates a new ReplaceColorBlock
  60106. * @param name defines the block name
  60107. */
  60108. constructor(name: string);
  60109. /**
  60110. * Gets the current class name
  60111. * @returns the class name
  60112. */
  60113. getClassName(): string;
  60114. /**
  60115. * Gets the value input component
  60116. */
  60117. get value(): NodeMaterialConnectionPoint;
  60118. /**
  60119. * Gets the reference input component
  60120. */
  60121. get reference(): NodeMaterialConnectionPoint;
  60122. /**
  60123. * Gets the distance input component
  60124. */
  60125. get distance(): NodeMaterialConnectionPoint;
  60126. /**
  60127. * Gets the replacement input component
  60128. */
  60129. get replacement(): NodeMaterialConnectionPoint;
  60130. /**
  60131. * Gets the output component
  60132. */
  60133. get output(): NodeMaterialConnectionPoint;
  60134. protected _buildBlock(state: NodeMaterialBuildState): this;
  60135. }
  60136. }
  60137. declare module BABYLON {
  60138. /**
  60139. * Block used to posterize a value
  60140. * @see https://en.wikipedia.org/wiki/Posterization
  60141. */
  60142. export class PosterizeBlock extends NodeMaterialBlock {
  60143. /**
  60144. * Creates a new PosterizeBlock
  60145. * @param name defines the block name
  60146. */
  60147. constructor(name: string);
  60148. /**
  60149. * Gets the current class name
  60150. * @returns the class name
  60151. */
  60152. getClassName(): string;
  60153. /**
  60154. * Gets the value input component
  60155. */
  60156. get value(): NodeMaterialConnectionPoint;
  60157. /**
  60158. * Gets the steps input component
  60159. */
  60160. get steps(): NodeMaterialConnectionPoint;
  60161. /**
  60162. * Gets the output component
  60163. */
  60164. get output(): NodeMaterialConnectionPoint;
  60165. protected _buildBlock(state: NodeMaterialBuildState): this;
  60166. }
  60167. }
  60168. declare module BABYLON {
  60169. /**
  60170. * Operations supported by the Wave block
  60171. */
  60172. export enum WaveBlockKind {
  60173. /** SawTooth */
  60174. SawTooth = 0,
  60175. /** Square */
  60176. Square = 1,
  60177. /** Triangle */
  60178. Triangle = 2
  60179. }
  60180. /**
  60181. * Block used to apply wave operation to floats
  60182. */
  60183. export class WaveBlock extends NodeMaterialBlock {
  60184. /**
  60185. * Gets or sets the kibnd of wave to be applied by the block
  60186. */
  60187. kind: WaveBlockKind;
  60188. /**
  60189. * Creates a new WaveBlock
  60190. * @param name defines the block name
  60191. */
  60192. constructor(name: string);
  60193. /**
  60194. * Gets the current class name
  60195. * @returns the class name
  60196. */
  60197. getClassName(): string;
  60198. /**
  60199. * Gets the input component
  60200. */
  60201. get input(): NodeMaterialConnectionPoint;
  60202. /**
  60203. * Gets the output component
  60204. */
  60205. get output(): NodeMaterialConnectionPoint;
  60206. protected _buildBlock(state: NodeMaterialBuildState): this;
  60207. serialize(): any;
  60208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60209. }
  60210. }
  60211. declare module BABYLON {
  60212. /**
  60213. * Class used to store a color step for the GradientBlock
  60214. */
  60215. export class GradientBlockColorStep {
  60216. /**
  60217. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60218. */
  60219. step: number;
  60220. /**
  60221. * Gets or sets the color associated with this step
  60222. */
  60223. color: Color3;
  60224. /**
  60225. * Creates a new GradientBlockColorStep
  60226. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60227. * @param color defines the color associated with this step
  60228. */
  60229. constructor(
  60230. /**
  60231. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60232. */
  60233. step: number,
  60234. /**
  60235. * Gets or sets the color associated with this step
  60236. */
  60237. color: Color3);
  60238. }
  60239. /**
  60240. * Block used to return a color from a gradient based on an input value between 0 and 1
  60241. */
  60242. export class GradientBlock extends NodeMaterialBlock {
  60243. /**
  60244. * Gets or sets the list of color steps
  60245. */
  60246. colorSteps: GradientBlockColorStep[];
  60247. /**
  60248. * Creates a new GradientBlock
  60249. * @param name defines the block name
  60250. */
  60251. constructor(name: string);
  60252. /**
  60253. * Gets the current class name
  60254. * @returns the class name
  60255. */
  60256. getClassName(): string;
  60257. /**
  60258. * Gets the gradient input component
  60259. */
  60260. get gradient(): NodeMaterialConnectionPoint;
  60261. /**
  60262. * Gets the output component
  60263. */
  60264. get output(): NodeMaterialConnectionPoint;
  60265. private _writeColorConstant;
  60266. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60267. serialize(): any;
  60268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60269. protected _dumpPropertiesCode(): string;
  60270. }
  60271. }
  60272. declare module BABYLON {
  60273. /**
  60274. * Block used to normalize lerp between 2 values
  60275. */
  60276. export class NLerpBlock extends NodeMaterialBlock {
  60277. /**
  60278. * Creates a new NLerpBlock
  60279. * @param name defines the block name
  60280. */
  60281. constructor(name: string);
  60282. /**
  60283. * Gets the current class name
  60284. * @returns the class name
  60285. */
  60286. getClassName(): string;
  60287. /**
  60288. * Gets the left operand input component
  60289. */
  60290. get left(): NodeMaterialConnectionPoint;
  60291. /**
  60292. * Gets the right operand input component
  60293. */
  60294. get right(): NodeMaterialConnectionPoint;
  60295. /**
  60296. * Gets the gradient operand input component
  60297. */
  60298. get gradient(): NodeMaterialConnectionPoint;
  60299. /**
  60300. * Gets the output component
  60301. */
  60302. get output(): NodeMaterialConnectionPoint;
  60303. protected _buildBlock(state: NodeMaterialBuildState): this;
  60304. }
  60305. }
  60306. declare module BABYLON {
  60307. /**
  60308. * block used to Generate a Worley Noise 3D Noise Pattern
  60309. */
  60310. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60311. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60312. manhattanDistance: boolean;
  60313. /**
  60314. * Creates a new WorleyNoise3DBlock
  60315. * @param name defines the block name
  60316. */
  60317. constructor(name: string);
  60318. /**
  60319. * Gets the current class name
  60320. * @returns the class name
  60321. */
  60322. getClassName(): string;
  60323. /**
  60324. * Gets the seed input component
  60325. */
  60326. get seed(): NodeMaterialConnectionPoint;
  60327. /**
  60328. * Gets the jitter input component
  60329. */
  60330. get jitter(): NodeMaterialConnectionPoint;
  60331. /**
  60332. * Gets the output component
  60333. */
  60334. get output(): NodeMaterialConnectionPoint;
  60335. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60336. /**
  60337. * Exposes the properties to the UI?
  60338. */
  60339. protected _dumpPropertiesCode(): string;
  60340. /**
  60341. * Exposes the properties to the Seralize?
  60342. */
  60343. serialize(): any;
  60344. /**
  60345. * Exposes the properties to the deseralize?
  60346. */
  60347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60348. }
  60349. }
  60350. declare module BABYLON {
  60351. /**
  60352. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60353. */
  60354. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60355. /**
  60356. * Creates a new SimplexPerlin3DBlock
  60357. * @param name defines the block name
  60358. */
  60359. constructor(name: string);
  60360. /**
  60361. * Gets the current class name
  60362. * @returns the class name
  60363. */
  60364. getClassName(): string;
  60365. /**
  60366. * Gets the seed operand input component
  60367. */
  60368. get seed(): NodeMaterialConnectionPoint;
  60369. /**
  60370. * Gets the output component
  60371. */
  60372. get output(): NodeMaterialConnectionPoint;
  60373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60374. }
  60375. }
  60376. declare module BABYLON {
  60377. /**
  60378. * Block used to blend normals
  60379. */
  60380. export class NormalBlendBlock extends NodeMaterialBlock {
  60381. /**
  60382. * Creates a new NormalBlendBlock
  60383. * @param name defines the block name
  60384. */
  60385. constructor(name: string);
  60386. /**
  60387. * Gets the current class name
  60388. * @returns the class name
  60389. */
  60390. getClassName(): string;
  60391. /**
  60392. * Gets the first input component
  60393. */
  60394. get normalMap0(): NodeMaterialConnectionPoint;
  60395. /**
  60396. * Gets the second input component
  60397. */
  60398. get normalMap1(): NodeMaterialConnectionPoint;
  60399. /**
  60400. * Gets the output component
  60401. */
  60402. get output(): NodeMaterialConnectionPoint;
  60403. protected _buildBlock(state: NodeMaterialBuildState): this;
  60404. }
  60405. }
  60406. declare module BABYLON {
  60407. /**
  60408. * Block used to rotate a 2d vector by a given angle
  60409. */
  60410. export class Rotate2dBlock extends NodeMaterialBlock {
  60411. /**
  60412. * Creates a new Rotate2dBlock
  60413. * @param name defines the block name
  60414. */
  60415. constructor(name: string);
  60416. /**
  60417. * Gets the current class name
  60418. * @returns the class name
  60419. */
  60420. getClassName(): string;
  60421. /**
  60422. * Gets the input vector
  60423. */
  60424. get input(): NodeMaterialConnectionPoint;
  60425. /**
  60426. * Gets the input angle
  60427. */
  60428. get angle(): NodeMaterialConnectionPoint;
  60429. /**
  60430. * Gets the output component
  60431. */
  60432. get output(): NodeMaterialConnectionPoint;
  60433. autoConfigure(material: NodeMaterial): void;
  60434. protected _buildBlock(state: NodeMaterialBuildState): this;
  60435. }
  60436. }
  60437. declare module BABYLON {
  60438. /**
  60439. * Block used to get the reflected vector from a direction and a normal
  60440. */
  60441. export class ReflectBlock extends NodeMaterialBlock {
  60442. /**
  60443. * Creates a new ReflectBlock
  60444. * @param name defines the block name
  60445. */
  60446. constructor(name: string);
  60447. /**
  60448. * Gets the current class name
  60449. * @returns the class name
  60450. */
  60451. getClassName(): string;
  60452. /**
  60453. * Gets the incident component
  60454. */
  60455. get incident(): NodeMaterialConnectionPoint;
  60456. /**
  60457. * Gets the normal component
  60458. */
  60459. get normal(): NodeMaterialConnectionPoint;
  60460. /**
  60461. * Gets the output component
  60462. */
  60463. get output(): NodeMaterialConnectionPoint;
  60464. protected _buildBlock(state: NodeMaterialBuildState): this;
  60465. }
  60466. }
  60467. declare module BABYLON {
  60468. /**
  60469. * Block used to get the refracted vector from a direction and a normal
  60470. */
  60471. export class RefractBlock extends NodeMaterialBlock {
  60472. /**
  60473. * Creates a new RefractBlock
  60474. * @param name defines the block name
  60475. */
  60476. constructor(name: string);
  60477. /**
  60478. * Gets the current class name
  60479. * @returns the class name
  60480. */
  60481. getClassName(): string;
  60482. /**
  60483. * Gets the incident component
  60484. */
  60485. get incident(): NodeMaterialConnectionPoint;
  60486. /**
  60487. * Gets the normal component
  60488. */
  60489. get normal(): NodeMaterialConnectionPoint;
  60490. /**
  60491. * Gets the index of refraction component
  60492. */
  60493. get ior(): NodeMaterialConnectionPoint;
  60494. /**
  60495. * Gets the output component
  60496. */
  60497. get output(): NodeMaterialConnectionPoint;
  60498. protected _buildBlock(state: NodeMaterialBuildState): this;
  60499. }
  60500. }
  60501. declare module BABYLON {
  60502. /**
  60503. * Block used to desaturate a color
  60504. */
  60505. export class DesaturateBlock extends NodeMaterialBlock {
  60506. /**
  60507. * Creates a new DesaturateBlock
  60508. * @param name defines the block name
  60509. */
  60510. constructor(name: string);
  60511. /**
  60512. * Gets the current class name
  60513. * @returns the class name
  60514. */
  60515. getClassName(): string;
  60516. /**
  60517. * Gets the color operand input component
  60518. */
  60519. get color(): NodeMaterialConnectionPoint;
  60520. /**
  60521. * Gets the level operand input component
  60522. */
  60523. get level(): NodeMaterialConnectionPoint;
  60524. /**
  60525. * Gets the output component
  60526. */
  60527. get output(): NodeMaterialConnectionPoint;
  60528. protected _buildBlock(state: NodeMaterialBuildState): this;
  60529. }
  60530. }
  60531. declare module BABYLON {
  60532. /**
  60533. * Effect Render Options
  60534. */
  60535. export interface IEffectRendererOptions {
  60536. /**
  60537. * Defines the vertices positions.
  60538. */
  60539. positions?: number[];
  60540. /**
  60541. * Defines the indices.
  60542. */
  60543. indices?: number[];
  60544. }
  60545. /**
  60546. * Helper class to render one or more effects
  60547. */
  60548. export class EffectRenderer {
  60549. private engine;
  60550. private static _DefaultOptions;
  60551. private _vertexBuffers;
  60552. private _indexBuffer;
  60553. private _ringBufferIndex;
  60554. private _ringScreenBuffer;
  60555. private _fullscreenViewport;
  60556. private _getNextFrameBuffer;
  60557. /**
  60558. * Creates an effect renderer
  60559. * @param engine the engine to use for rendering
  60560. * @param options defines the options of the effect renderer
  60561. */
  60562. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60563. /**
  60564. * Sets the current viewport in normalized coordinates 0-1
  60565. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60566. */
  60567. setViewport(viewport?: Viewport): void;
  60568. /**
  60569. * Binds the embedded attributes buffer to the effect.
  60570. * @param effect Defines the effect to bind the attributes for
  60571. */
  60572. bindBuffers(effect: Effect): void;
  60573. /**
  60574. * Sets the current effect wrapper to use during draw.
  60575. * The effect needs to be ready before calling this api.
  60576. * This also sets the default full screen position attribute.
  60577. * @param effectWrapper Defines the effect to draw with
  60578. */
  60579. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60580. /**
  60581. * Draws a full screen quad.
  60582. */
  60583. draw(): void;
  60584. /**
  60585. * renders one or more effects to a specified texture
  60586. * @param effectWrappers list of effects to renderer
  60587. * @param outputTexture texture to draw to, if null it will render to the screen
  60588. */
  60589. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60590. /**
  60591. * Disposes of the effect renderer
  60592. */
  60593. dispose(): void;
  60594. }
  60595. /**
  60596. * Options to create an EffectWrapper
  60597. */
  60598. interface EffectWrapperCreationOptions {
  60599. /**
  60600. * Engine to use to create the effect
  60601. */
  60602. engine: ThinEngine;
  60603. /**
  60604. * Fragment shader for the effect
  60605. */
  60606. fragmentShader: string;
  60607. /**
  60608. * Vertex shader for the effect
  60609. */
  60610. vertexShader?: string;
  60611. /**
  60612. * Attributes to use in the shader
  60613. */
  60614. attributeNames?: Array<string>;
  60615. /**
  60616. * Uniforms to use in the shader
  60617. */
  60618. uniformNames?: Array<string>;
  60619. /**
  60620. * Texture sampler names to use in the shader
  60621. */
  60622. samplerNames?: Array<string>;
  60623. /**
  60624. * The friendly name of the effect displayed in Spector.
  60625. */
  60626. name?: string;
  60627. }
  60628. /**
  60629. * Wraps an effect to be used for rendering
  60630. */
  60631. export class EffectWrapper {
  60632. /**
  60633. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60634. */
  60635. onApplyObservable: Observable<{}>;
  60636. /**
  60637. * The underlying effect
  60638. */
  60639. effect: Effect;
  60640. /**
  60641. * Creates an effect to be renderer
  60642. * @param creationOptions options to create the effect
  60643. */
  60644. constructor(creationOptions: EffectWrapperCreationOptions);
  60645. /**
  60646. * Disposes of the effect wrapper
  60647. */
  60648. dispose(): void;
  60649. }
  60650. }
  60651. declare module BABYLON {
  60652. /**
  60653. * Helper class to push actions to a pool of workers.
  60654. */
  60655. export class WorkerPool implements IDisposable {
  60656. private _workerInfos;
  60657. private _pendingActions;
  60658. /**
  60659. * Constructor
  60660. * @param workers Array of workers to use for actions
  60661. */
  60662. constructor(workers: Array<Worker>);
  60663. /**
  60664. * Terminates all workers and clears any pending actions.
  60665. */
  60666. dispose(): void;
  60667. /**
  60668. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60669. * pended until a worker has completed its action.
  60670. * @param action The action to perform. Call onComplete when the action is complete.
  60671. */
  60672. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60673. private _execute;
  60674. }
  60675. }
  60676. declare module BABYLON {
  60677. /**
  60678. * Configuration for Draco compression
  60679. */
  60680. export interface IDracoCompressionConfiguration {
  60681. /**
  60682. * Configuration for the decoder.
  60683. */
  60684. decoder: {
  60685. /**
  60686. * The url to the WebAssembly module.
  60687. */
  60688. wasmUrl?: string;
  60689. /**
  60690. * The url to the WebAssembly binary.
  60691. */
  60692. wasmBinaryUrl?: string;
  60693. /**
  60694. * The url to the fallback JavaScript module.
  60695. */
  60696. fallbackUrl?: string;
  60697. };
  60698. }
  60699. /**
  60700. * Draco compression (https://google.github.io/draco/)
  60701. *
  60702. * This class wraps the Draco module.
  60703. *
  60704. * **Encoder**
  60705. *
  60706. * The encoder is not currently implemented.
  60707. *
  60708. * **Decoder**
  60709. *
  60710. * 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.
  60711. *
  60712. * To update the configuration, use the following code:
  60713. * ```javascript
  60714. * DracoCompression.Configuration = {
  60715. * decoder: {
  60716. * wasmUrl: "<url to the WebAssembly library>",
  60717. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60718. * fallbackUrl: "<url to the fallback JavaScript library>",
  60719. * }
  60720. * };
  60721. * ```
  60722. *
  60723. * 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.
  60724. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60725. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60726. *
  60727. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60728. * ```javascript
  60729. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60730. * ```
  60731. *
  60732. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60733. */
  60734. export class DracoCompression implements IDisposable {
  60735. private _workerPoolPromise?;
  60736. private _decoderModulePromise?;
  60737. /**
  60738. * The configuration. Defaults to the following urls:
  60739. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60740. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60741. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60742. */
  60743. static Configuration: IDracoCompressionConfiguration;
  60744. /**
  60745. * Returns true if the decoder configuration is available.
  60746. */
  60747. static get DecoderAvailable(): boolean;
  60748. /**
  60749. * Default number of workers to create when creating the draco compression object.
  60750. */
  60751. static DefaultNumWorkers: number;
  60752. private static GetDefaultNumWorkers;
  60753. private static _Default;
  60754. /**
  60755. * Default instance for the draco compression object.
  60756. */
  60757. static get Default(): DracoCompression;
  60758. /**
  60759. * Constructor
  60760. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60761. */
  60762. constructor(numWorkers?: number);
  60763. /**
  60764. * Stop all async operations and release resources.
  60765. */
  60766. dispose(): void;
  60767. /**
  60768. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60769. * @returns a promise that resolves when ready
  60770. */
  60771. whenReadyAsync(): Promise<void>;
  60772. /**
  60773. * Decode Draco compressed mesh data to vertex data.
  60774. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60775. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60776. * @returns A promise that resolves with the decoded vertex data
  60777. */
  60778. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60779. [kind: string]: number;
  60780. }): Promise<VertexData>;
  60781. }
  60782. }
  60783. declare module BABYLON {
  60784. /**
  60785. * Class for building Constructive Solid Geometry
  60786. */
  60787. export class CSG {
  60788. private polygons;
  60789. /**
  60790. * The world matrix
  60791. */
  60792. matrix: Matrix;
  60793. /**
  60794. * Stores the position
  60795. */
  60796. position: Vector3;
  60797. /**
  60798. * Stores the rotation
  60799. */
  60800. rotation: Vector3;
  60801. /**
  60802. * Stores the rotation quaternion
  60803. */
  60804. rotationQuaternion: Nullable<Quaternion>;
  60805. /**
  60806. * Stores the scaling vector
  60807. */
  60808. scaling: Vector3;
  60809. /**
  60810. * Convert the Mesh to CSG
  60811. * @param mesh The Mesh to convert to CSG
  60812. * @returns A new CSG from the Mesh
  60813. */
  60814. static FromMesh(mesh: Mesh): CSG;
  60815. /**
  60816. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60817. * @param polygons Polygons used to construct a CSG solid
  60818. */
  60819. private static FromPolygons;
  60820. /**
  60821. * Clones, or makes a deep copy, of the CSG
  60822. * @returns A new CSG
  60823. */
  60824. clone(): CSG;
  60825. /**
  60826. * Unions this CSG with another CSG
  60827. * @param csg The CSG to union against this CSG
  60828. * @returns The unioned CSG
  60829. */
  60830. union(csg: CSG): CSG;
  60831. /**
  60832. * Unions this CSG with another CSG in place
  60833. * @param csg The CSG to union against this CSG
  60834. */
  60835. unionInPlace(csg: CSG): void;
  60836. /**
  60837. * Subtracts this CSG with another CSG
  60838. * @param csg The CSG to subtract against this CSG
  60839. * @returns A new CSG
  60840. */
  60841. subtract(csg: CSG): CSG;
  60842. /**
  60843. * Subtracts this CSG with another CSG in place
  60844. * @param csg The CSG to subtact against this CSG
  60845. */
  60846. subtractInPlace(csg: CSG): void;
  60847. /**
  60848. * Intersect this CSG with another CSG
  60849. * @param csg The CSG to intersect against this CSG
  60850. * @returns A new CSG
  60851. */
  60852. intersect(csg: CSG): CSG;
  60853. /**
  60854. * Intersects this CSG with another CSG in place
  60855. * @param csg The CSG to intersect against this CSG
  60856. */
  60857. intersectInPlace(csg: CSG): void;
  60858. /**
  60859. * Return a new CSG solid with solid and empty space switched. This solid is
  60860. * not modified.
  60861. * @returns A new CSG solid with solid and empty space switched
  60862. */
  60863. inverse(): CSG;
  60864. /**
  60865. * Inverses the CSG in place
  60866. */
  60867. inverseInPlace(): void;
  60868. /**
  60869. * This is used to keep meshes transformations so they can be restored
  60870. * when we build back a Babylon Mesh
  60871. * NB : All CSG operations are performed in world coordinates
  60872. * @param csg The CSG to copy the transform attributes from
  60873. * @returns This CSG
  60874. */
  60875. copyTransformAttributes(csg: CSG): CSG;
  60876. /**
  60877. * Build Raw mesh from CSG
  60878. * Coordinates here are in world space
  60879. * @param name The name of the mesh geometry
  60880. * @param scene The Scene
  60881. * @param keepSubMeshes Specifies if the submeshes should be kept
  60882. * @returns A new Mesh
  60883. */
  60884. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60885. /**
  60886. * Build Mesh from CSG taking material and transforms into account
  60887. * @param name The name of the Mesh
  60888. * @param material The material of the Mesh
  60889. * @param scene The Scene
  60890. * @param keepSubMeshes Specifies if submeshes should be kept
  60891. * @returns The new Mesh
  60892. */
  60893. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60894. }
  60895. }
  60896. declare module BABYLON {
  60897. /**
  60898. * Class used to create a trail following a mesh
  60899. */
  60900. export class TrailMesh extends Mesh {
  60901. private _generator;
  60902. private _autoStart;
  60903. private _running;
  60904. private _diameter;
  60905. private _length;
  60906. private _sectionPolygonPointsCount;
  60907. private _sectionVectors;
  60908. private _sectionNormalVectors;
  60909. private _beforeRenderObserver;
  60910. /**
  60911. * @constructor
  60912. * @param name The value used by scene.getMeshByName() to do a lookup.
  60913. * @param generator The mesh or transform node to generate a trail.
  60914. * @param scene The scene to add this mesh to.
  60915. * @param diameter Diameter of trailing mesh. Default is 1.
  60916. * @param length Length of trailing mesh. Default is 60.
  60917. * @param autoStart Automatically start trailing mesh. Default true.
  60918. */
  60919. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60920. /**
  60921. * "TrailMesh"
  60922. * @returns "TrailMesh"
  60923. */
  60924. getClassName(): string;
  60925. private _createMesh;
  60926. /**
  60927. * Start trailing mesh.
  60928. */
  60929. start(): void;
  60930. /**
  60931. * Stop trailing mesh.
  60932. */
  60933. stop(): void;
  60934. /**
  60935. * Update trailing mesh geometry.
  60936. */
  60937. update(): void;
  60938. /**
  60939. * Returns a new TrailMesh object.
  60940. * @param name is a string, the name given to the new mesh
  60941. * @param newGenerator use new generator object for cloned trail mesh
  60942. * @returns a new mesh
  60943. */
  60944. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60945. /**
  60946. * Serializes this trail mesh
  60947. * @param serializationObject object to write serialization to
  60948. */
  60949. serialize(serializationObject: any): void;
  60950. /**
  60951. * Parses a serialized trail mesh
  60952. * @param parsedMesh the serialized mesh
  60953. * @param scene the scene to create the trail mesh in
  60954. * @returns the created trail mesh
  60955. */
  60956. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60957. }
  60958. }
  60959. declare module BABYLON {
  60960. /**
  60961. * Class containing static functions to help procedurally build meshes
  60962. */
  60963. export class TiledBoxBuilder {
  60964. /**
  60965. * Creates a box mesh
  60966. * 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)
  60967. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60969. * * 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
  60970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60971. * @param name defines the name of the mesh
  60972. * @param options defines the options used to create the mesh
  60973. * @param scene defines the hosting scene
  60974. * @returns the box mesh
  60975. */
  60976. static CreateTiledBox(name: string, options: {
  60977. pattern?: number;
  60978. width?: number;
  60979. height?: number;
  60980. depth?: number;
  60981. tileSize?: number;
  60982. tileWidth?: number;
  60983. tileHeight?: number;
  60984. alignHorizontal?: number;
  60985. alignVertical?: number;
  60986. faceUV?: Vector4[];
  60987. faceColors?: Color4[];
  60988. sideOrientation?: number;
  60989. updatable?: boolean;
  60990. }, scene?: Nullable<Scene>): Mesh;
  60991. }
  60992. }
  60993. declare module BABYLON {
  60994. /**
  60995. * Class containing static functions to help procedurally build meshes
  60996. */
  60997. export class TorusKnotBuilder {
  60998. /**
  60999. * Creates a torus knot mesh
  61000. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61001. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61002. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61003. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61005. * * 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
  61006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  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 torus knot mesh
  61011. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61012. */
  61013. static CreateTorusKnot(name: string, options: {
  61014. radius?: number;
  61015. tube?: number;
  61016. radialSegments?: number;
  61017. tubularSegments?: number;
  61018. p?: number;
  61019. q?: number;
  61020. updatable?: boolean;
  61021. sideOrientation?: number;
  61022. frontUVs?: Vector4;
  61023. backUVs?: Vector4;
  61024. }, scene: any): Mesh;
  61025. }
  61026. }
  61027. declare module BABYLON {
  61028. /**
  61029. * Polygon
  61030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61031. */
  61032. export class Polygon {
  61033. /**
  61034. * Creates a rectangle
  61035. * @param xmin bottom X coord
  61036. * @param ymin bottom Y coord
  61037. * @param xmax top X coord
  61038. * @param ymax top Y coord
  61039. * @returns points that make the resulting rectation
  61040. */
  61041. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61042. /**
  61043. * Creates a circle
  61044. * @param radius radius of circle
  61045. * @param cx scale in x
  61046. * @param cy scale in y
  61047. * @param numberOfSides number of sides that make up the circle
  61048. * @returns points that make the resulting circle
  61049. */
  61050. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61051. /**
  61052. * Creates a polygon from input string
  61053. * @param input Input polygon data
  61054. * @returns the parsed points
  61055. */
  61056. static Parse(input: string): Vector2[];
  61057. /**
  61058. * Starts building a polygon from x and y coordinates
  61059. * @param x x coordinate
  61060. * @param y y coordinate
  61061. * @returns the started path2
  61062. */
  61063. static StartingAt(x: number, y: number): Path2;
  61064. }
  61065. /**
  61066. * Builds a polygon
  61067. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61068. */
  61069. export class PolygonMeshBuilder {
  61070. private _points;
  61071. private _outlinepoints;
  61072. private _holes;
  61073. private _name;
  61074. private _scene;
  61075. private _epoints;
  61076. private _eholes;
  61077. private _addToepoint;
  61078. /**
  61079. * Babylon reference to the earcut plugin.
  61080. */
  61081. bjsEarcut: any;
  61082. /**
  61083. * Creates a PolygonMeshBuilder
  61084. * @param name name of the builder
  61085. * @param contours Path of the polygon
  61086. * @param scene scene to add to when creating the mesh
  61087. * @param earcutInjection can be used to inject your own earcut reference
  61088. */
  61089. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61090. /**
  61091. * Adds a whole within the polygon
  61092. * @param hole Array of points defining the hole
  61093. * @returns this
  61094. */
  61095. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61096. /**
  61097. * Creates the polygon
  61098. * @param updatable If the mesh should be updatable
  61099. * @param depth The depth of the mesh created
  61100. * @returns the created mesh
  61101. */
  61102. build(updatable?: boolean, depth?: number): Mesh;
  61103. /**
  61104. * Creates the polygon
  61105. * @param depth The depth of the mesh created
  61106. * @returns the created VertexData
  61107. */
  61108. buildVertexData(depth?: number): VertexData;
  61109. /**
  61110. * Adds a side to the polygon
  61111. * @param positions points that make the polygon
  61112. * @param normals normals of the polygon
  61113. * @param uvs uvs of the polygon
  61114. * @param indices indices of the polygon
  61115. * @param bounds bounds of the polygon
  61116. * @param points points of the polygon
  61117. * @param depth depth of the polygon
  61118. * @param flip flip of the polygon
  61119. */
  61120. private addSide;
  61121. }
  61122. }
  61123. declare module BABYLON {
  61124. /**
  61125. * Class containing static functions to help procedurally build meshes
  61126. */
  61127. export class PolygonBuilder {
  61128. /**
  61129. * Creates a polygon mesh
  61130. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61131. * * 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
  61132. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61134. * * 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)
  61135. * * Remember you can only change the shape positions, not their number when updating a polygon
  61136. * @param name defines the name of the mesh
  61137. * @param options defines the options used to create the mesh
  61138. * @param scene defines the hosting scene
  61139. * @param earcutInjection can be used to inject your own earcut reference
  61140. * @returns the polygon mesh
  61141. */
  61142. static CreatePolygon(name: string, options: {
  61143. shape: Vector3[];
  61144. holes?: Vector3[][];
  61145. depth?: number;
  61146. faceUV?: Vector4[];
  61147. faceColors?: Color4[];
  61148. updatable?: boolean;
  61149. sideOrientation?: number;
  61150. frontUVs?: Vector4;
  61151. backUVs?: Vector4;
  61152. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61153. /**
  61154. * Creates an extruded polygon mesh, with depth in the Y direction.
  61155. * * 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)
  61156. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61157. * @param name defines the name of the mesh
  61158. * @param options defines the options used to create the mesh
  61159. * @param scene defines the hosting scene
  61160. * @param earcutInjection can be used to inject your own earcut reference
  61161. * @returns the polygon mesh
  61162. */
  61163. static ExtrudePolygon(name: string, options: {
  61164. shape: Vector3[];
  61165. holes?: Vector3[][];
  61166. depth?: number;
  61167. faceUV?: Vector4[];
  61168. faceColors?: Color4[];
  61169. updatable?: boolean;
  61170. sideOrientation?: number;
  61171. frontUVs?: Vector4;
  61172. backUVs?: Vector4;
  61173. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61174. }
  61175. }
  61176. declare module BABYLON {
  61177. /**
  61178. * Class containing static functions to help procedurally build meshes
  61179. */
  61180. export class LatheBuilder {
  61181. /**
  61182. * Creates lathe mesh.
  61183. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61184. * * 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
  61185. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61186. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61187. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61188. * * 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
  61189. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61190. * * 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
  61191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61192. * * 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
  61193. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61195. * @param name defines the name of the mesh
  61196. * @param options defines the options used to create the mesh
  61197. * @param scene defines the hosting scene
  61198. * @returns the lathe mesh
  61199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61200. */
  61201. static CreateLathe(name: string, options: {
  61202. shape: Vector3[];
  61203. radius?: number;
  61204. tessellation?: number;
  61205. clip?: number;
  61206. arc?: number;
  61207. closed?: boolean;
  61208. updatable?: boolean;
  61209. sideOrientation?: number;
  61210. frontUVs?: Vector4;
  61211. backUVs?: Vector4;
  61212. cap?: number;
  61213. invertUV?: boolean;
  61214. }, scene?: Nullable<Scene>): Mesh;
  61215. }
  61216. }
  61217. declare module BABYLON {
  61218. /**
  61219. * Class containing static functions to help procedurally build meshes
  61220. */
  61221. export class TiledPlaneBuilder {
  61222. /**
  61223. * Creates a tiled plane mesh
  61224. * * The parameter `pattern` will, depending on value, do nothing or
  61225. * * * flip (reflect about central vertical) alternate tiles across and up
  61226. * * * flip every tile on alternate rows
  61227. * * * rotate (180 degs) alternate tiles across and up
  61228. * * * rotate every tile on alternate rows
  61229. * * * flip and rotate alternate tiles across and up
  61230. * * * flip and rotate every tile on alternate rows
  61231. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61232. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61233. * * 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
  61234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61235. * * 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)
  61236. * * 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)
  61237. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61238. * @param name defines the name of the mesh
  61239. * @param options defines the options used to create the mesh
  61240. * @param scene defines the hosting scene
  61241. * @returns the box mesh
  61242. */
  61243. static CreateTiledPlane(name: string, options: {
  61244. pattern?: number;
  61245. tileSize?: number;
  61246. tileWidth?: number;
  61247. tileHeight?: number;
  61248. size?: number;
  61249. width?: number;
  61250. height?: number;
  61251. alignHorizontal?: number;
  61252. alignVertical?: number;
  61253. sideOrientation?: number;
  61254. frontUVs?: Vector4;
  61255. backUVs?: Vector4;
  61256. updatable?: boolean;
  61257. }, scene?: Nullable<Scene>): Mesh;
  61258. }
  61259. }
  61260. declare module BABYLON {
  61261. /**
  61262. * Class containing static functions to help procedurally build meshes
  61263. */
  61264. export class TubeBuilder {
  61265. /**
  61266. * Creates a tube mesh.
  61267. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61268. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61269. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61270. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61271. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61272. * * 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)
  61273. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61274. * * 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
  61275. * * 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
  61276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61277. * * 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
  61278. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61280. * @param name defines the name of the mesh
  61281. * @param options defines the options used to create the mesh
  61282. * @param scene defines the hosting scene
  61283. * @returns the tube mesh
  61284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61285. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61286. */
  61287. static CreateTube(name: string, options: {
  61288. path: Vector3[];
  61289. radius?: number;
  61290. tessellation?: number;
  61291. radiusFunction?: {
  61292. (i: number, distance: number): number;
  61293. };
  61294. cap?: number;
  61295. arc?: number;
  61296. updatable?: boolean;
  61297. sideOrientation?: number;
  61298. frontUVs?: Vector4;
  61299. backUVs?: Vector4;
  61300. instance?: Mesh;
  61301. invertUV?: boolean;
  61302. }, scene?: Nullable<Scene>): Mesh;
  61303. }
  61304. }
  61305. declare module BABYLON {
  61306. /**
  61307. * Class containing static functions to help procedurally build meshes
  61308. */
  61309. export class IcoSphereBuilder {
  61310. /**
  61311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61313. * * 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`)
  61314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61315. * * 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
  61316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61317. * * 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
  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 icosahedron mesh
  61323. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61324. */
  61325. static CreateIcoSphere(name: string, options: {
  61326. radius?: number;
  61327. radiusX?: number;
  61328. radiusY?: number;
  61329. radiusZ?: number;
  61330. flat?: boolean;
  61331. subdivisions?: number;
  61332. sideOrientation?: number;
  61333. frontUVs?: Vector4;
  61334. backUVs?: Vector4;
  61335. updatable?: boolean;
  61336. }, scene?: Nullable<Scene>): Mesh;
  61337. }
  61338. }
  61339. declare module BABYLON {
  61340. /**
  61341. * Class containing static functions to help procedurally build meshes
  61342. */
  61343. export class DecalBuilder {
  61344. /**
  61345. * Creates a decal mesh.
  61346. * 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
  61347. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61348. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61349. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61350. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61351. * @param name defines the name of the mesh
  61352. * @param sourceMesh defines the mesh where the decal must be applied
  61353. * @param options defines the options used to create the mesh
  61354. * @param scene defines the hosting scene
  61355. * @returns the decal mesh
  61356. * @see https://doc.babylonjs.com/how_to/decals
  61357. */
  61358. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61359. position?: Vector3;
  61360. normal?: Vector3;
  61361. size?: Vector3;
  61362. angle?: number;
  61363. }): Mesh;
  61364. }
  61365. }
  61366. declare module BABYLON {
  61367. /**
  61368. * Class containing static functions to help procedurally build meshes
  61369. */
  61370. export class MeshBuilder {
  61371. /**
  61372. * Creates a box mesh
  61373. * * The parameter `size` sets the size (float) of each box side (default 1)
  61374. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61375. * * 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)
  61376. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61378. * * 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
  61379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61380. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61381. * @param name defines the name of the mesh
  61382. * @param options defines the options used to create the mesh
  61383. * @param scene defines the hosting scene
  61384. * @returns the box mesh
  61385. */
  61386. static CreateBox(name: string, options: {
  61387. size?: number;
  61388. width?: number;
  61389. height?: number;
  61390. depth?: number;
  61391. faceUV?: Vector4[];
  61392. faceColors?: Color4[];
  61393. sideOrientation?: number;
  61394. frontUVs?: Vector4;
  61395. backUVs?: Vector4;
  61396. wrap?: boolean;
  61397. topBaseAt?: number;
  61398. bottomBaseAt?: number;
  61399. updatable?: boolean;
  61400. }, scene?: Nullable<Scene>): Mesh;
  61401. /**
  61402. * Creates a tiled box mesh
  61403. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61405. * @param name defines the name of the mesh
  61406. * @param options defines the options used to create the mesh
  61407. * @param scene defines the hosting scene
  61408. * @returns the tiled box mesh
  61409. */
  61410. static CreateTiledBox(name: string, options: {
  61411. pattern?: number;
  61412. size?: number;
  61413. width?: number;
  61414. height?: number;
  61415. depth: number;
  61416. tileSize?: number;
  61417. tileWidth?: number;
  61418. tileHeight?: number;
  61419. faceUV?: Vector4[];
  61420. faceColors?: Color4[];
  61421. alignHorizontal?: number;
  61422. alignVertical?: number;
  61423. sideOrientation?: number;
  61424. updatable?: boolean;
  61425. }, scene?: Nullable<Scene>): Mesh;
  61426. /**
  61427. * Creates a sphere mesh
  61428. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61429. * * 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`)
  61430. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61431. * * 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
  61432. * * 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)
  61433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61434. * * 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
  61435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61436. * @param name defines the name of the mesh
  61437. * @param options defines the options used to create the mesh
  61438. * @param scene defines the hosting scene
  61439. * @returns the sphere mesh
  61440. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61441. */
  61442. static CreateSphere(name: string, options: {
  61443. segments?: number;
  61444. diameter?: number;
  61445. diameterX?: number;
  61446. diameterY?: number;
  61447. diameterZ?: number;
  61448. arc?: number;
  61449. slice?: number;
  61450. sideOrientation?: number;
  61451. frontUVs?: Vector4;
  61452. backUVs?: Vector4;
  61453. updatable?: boolean;
  61454. }, scene?: Nullable<Scene>): Mesh;
  61455. /**
  61456. * Creates a plane polygonal mesh. By default, this is a disc
  61457. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61458. * * 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
  61459. * * 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
  61460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61461. * * 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
  61462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61463. * @param name defines the name of the mesh
  61464. * @param options defines the options used to create the mesh
  61465. * @param scene defines the hosting scene
  61466. * @returns the plane polygonal mesh
  61467. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61468. */
  61469. static CreateDisc(name: string, options: {
  61470. radius?: number;
  61471. tessellation?: number;
  61472. arc?: number;
  61473. updatable?: boolean;
  61474. sideOrientation?: number;
  61475. frontUVs?: Vector4;
  61476. backUVs?: Vector4;
  61477. }, scene?: Nullable<Scene>): Mesh;
  61478. /**
  61479. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61480. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61481. * * 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`)
  61482. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61483. * * 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
  61484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61485. * * 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
  61486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61487. * @param name defines the name of the mesh
  61488. * @param options defines the options used to create the mesh
  61489. * @param scene defines the hosting scene
  61490. * @returns the icosahedron mesh
  61491. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61492. */
  61493. static CreateIcoSphere(name: string, options: {
  61494. radius?: number;
  61495. radiusX?: number;
  61496. radiusY?: number;
  61497. radiusZ?: number;
  61498. flat?: boolean;
  61499. subdivisions?: number;
  61500. sideOrientation?: number;
  61501. frontUVs?: Vector4;
  61502. backUVs?: Vector4;
  61503. updatable?: boolean;
  61504. }, scene?: Nullable<Scene>): Mesh;
  61505. /**
  61506. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61507. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61508. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61509. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61510. * * 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
  61511. * * 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
  61512. * * 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
  61513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61514. * * 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
  61515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61516. * * 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
  61517. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61518. * * 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
  61519. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61521. * @param name defines the name of the mesh
  61522. * @param options defines the options used to create the mesh
  61523. * @param scene defines the hosting scene
  61524. * @returns the ribbon mesh
  61525. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61527. */
  61528. static CreateRibbon(name: string, options: {
  61529. pathArray: Vector3[][];
  61530. closeArray?: boolean;
  61531. closePath?: boolean;
  61532. offset?: number;
  61533. updatable?: boolean;
  61534. sideOrientation?: number;
  61535. frontUVs?: Vector4;
  61536. backUVs?: Vector4;
  61537. instance?: Mesh;
  61538. invertUV?: boolean;
  61539. uvs?: Vector2[];
  61540. colors?: Color4[];
  61541. }, scene?: Nullable<Scene>): Mesh;
  61542. /**
  61543. * Creates a cylinder or a cone mesh
  61544. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61545. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61546. * * 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.
  61547. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61548. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61549. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61550. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61551. * * 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).
  61552. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61553. * * 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).
  61554. * * 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
  61555. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61556. * * 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
  61557. * * 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.
  61558. * * If `enclose` is false, a ring surface is one element.
  61559. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61560. * * 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
  61561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61562. * * 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
  61563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61564. * @param name defines the name of the mesh
  61565. * @param options defines the options used to create the mesh
  61566. * @param scene defines the hosting scene
  61567. * @returns the cylinder mesh
  61568. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61569. */
  61570. static CreateCylinder(name: string, options: {
  61571. height?: number;
  61572. diameterTop?: number;
  61573. diameterBottom?: number;
  61574. diameter?: number;
  61575. tessellation?: number;
  61576. subdivisions?: number;
  61577. arc?: number;
  61578. faceColors?: Color4[];
  61579. faceUV?: Vector4[];
  61580. updatable?: boolean;
  61581. hasRings?: boolean;
  61582. enclose?: boolean;
  61583. cap?: number;
  61584. sideOrientation?: number;
  61585. frontUVs?: Vector4;
  61586. backUVs?: Vector4;
  61587. }, scene?: Nullable<Scene>): Mesh;
  61588. /**
  61589. * Creates a torus mesh
  61590. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61591. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61592. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61594. * * 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
  61595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61596. * @param name defines the name of the mesh
  61597. * @param options defines the options used to create the mesh
  61598. * @param scene defines the hosting scene
  61599. * @returns the torus mesh
  61600. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61601. */
  61602. static CreateTorus(name: string, options: {
  61603. diameter?: number;
  61604. thickness?: number;
  61605. tessellation?: number;
  61606. updatable?: boolean;
  61607. sideOrientation?: number;
  61608. frontUVs?: Vector4;
  61609. backUVs?: Vector4;
  61610. }, scene?: Nullable<Scene>): Mesh;
  61611. /**
  61612. * Creates a torus knot mesh
  61613. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61614. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61615. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61616. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61618. * * 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
  61619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61620. * @param name defines the name of the mesh
  61621. * @param options defines the options used to create the mesh
  61622. * @param scene defines the hosting scene
  61623. * @returns the torus knot mesh
  61624. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61625. */
  61626. static CreateTorusKnot(name: string, options: {
  61627. radius?: number;
  61628. tube?: number;
  61629. radialSegments?: number;
  61630. tubularSegments?: number;
  61631. p?: number;
  61632. q?: number;
  61633. updatable?: boolean;
  61634. sideOrientation?: number;
  61635. frontUVs?: Vector4;
  61636. backUVs?: Vector4;
  61637. }, scene?: Nullable<Scene>): Mesh;
  61638. /**
  61639. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61640. * * 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
  61641. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61642. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61643. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61644. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61645. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61646. * * 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
  61647. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61650. * @param name defines the name of the new line system
  61651. * @param options defines the options used to create the line system
  61652. * @param scene defines the hosting scene
  61653. * @returns a new line system mesh
  61654. */
  61655. static CreateLineSystem(name: string, options: {
  61656. lines: Vector3[][];
  61657. updatable?: boolean;
  61658. instance?: Nullable<LinesMesh>;
  61659. colors?: Nullable<Color4[][]>;
  61660. useVertexAlpha?: boolean;
  61661. }, scene: Nullable<Scene>): LinesMesh;
  61662. /**
  61663. * Creates a line mesh
  61664. * 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
  61665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61666. * * The parameter `points` is an array successive Vector3
  61667. * * 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
  61668. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61669. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61670. * * When updating an instance, remember that only point positions can change, not the number of points
  61671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61673. * @param name defines the name of the new line system
  61674. * @param options defines the options used to create the line system
  61675. * @param scene defines the hosting scene
  61676. * @returns a new line mesh
  61677. */
  61678. static CreateLines(name: string, options: {
  61679. points: Vector3[];
  61680. updatable?: boolean;
  61681. instance?: Nullable<LinesMesh>;
  61682. colors?: Color4[];
  61683. useVertexAlpha?: boolean;
  61684. }, scene?: Nullable<Scene>): LinesMesh;
  61685. /**
  61686. * Creates a dashed line mesh
  61687. * * 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
  61688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61689. * * The parameter `points` is an array successive Vector3
  61690. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61691. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61692. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61693. * * 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
  61694. * * When updating an instance, remember that only point positions can change, not the number of points
  61695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61696. * @param name defines the name of the mesh
  61697. * @param options defines the options used to create the mesh
  61698. * @param scene defines the hosting scene
  61699. * @returns the dashed line mesh
  61700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61701. */
  61702. static CreateDashedLines(name: string, options: {
  61703. points: Vector3[];
  61704. dashSize?: number;
  61705. gapSize?: number;
  61706. dashNb?: number;
  61707. updatable?: boolean;
  61708. instance?: LinesMesh;
  61709. }, scene?: Nullable<Scene>): LinesMesh;
  61710. /**
  61711. * 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.
  61712. * * 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.
  61713. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61714. * * 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.
  61715. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61716. * * 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
  61717. * * 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
  61718. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61720. * * 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
  61721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61723. * @param name defines the name of the mesh
  61724. * @param options defines the options used to create the mesh
  61725. * @param scene defines the hosting scene
  61726. * @returns the extruded shape mesh
  61727. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61729. */
  61730. static ExtrudeShape(name: string, options: {
  61731. shape: Vector3[];
  61732. path: Vector3[];
  61733. scale?: number;
  61734. rotation?: number;
  61735. cap?: number;
  61736. updatable?: boolean;
  61737. sideOrientation?: number;
  61738. frontUVs?: Vector4;
  61739. backUVs?: Vector4;
  61740. instance?: Mesh;
  61741. invertUV?: boolean;
  61742. }, scene?: Nullable<Scene>): Mesh;
  61743. /**
  61744. * Creates an custom extruded shape mesh.
  61745. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61746. * * 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.
  61747. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61748. * * 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
  61749. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61750. * * 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
  61751. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61752. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61753. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61754. * * 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
  61755. * * 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
  61756. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61758. * * 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
  61759. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61761. * @param name defines the name of the mesh
  61762. * @param options defines the options used to create the mesh
  61763. * @param scene defines the hosting scene
  61764. * @returns the custom extruded shape mesh
  61765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61766. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61768. */
  61769. static ExtrudeShapeCustom(name: string, options: {
  61770. shape: Vector3[];
  61771. path: Vector3[];
  61772. scaleFunction?: any;
  61773. rotationFunction?: any;
  61774. ribbonCloseArray?: boolean;
  61775. ribbonClosePath?: boolean;
  61776. cap?: number;
  61777. updatable?: boolean;
  61778. sideOrientation?: number;
  61779. frontUVs?: Vector4;
  61780. backUVs?: Vector4;
  61781. instance?: Mesh;
  61782. invertUV?: boolean;
  61783. }, scene?: Nullable<Scene>): Mesh;
  61784. /**
  61785. * Creates lathe mesh.
  61786. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61787. * * 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
  61788. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61789. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61790. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61791. * * 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
  61792. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61793. * * 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
  61794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61795. * * 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
  61796. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61798. * @param name defines the name of the mesh
  61799. * @param options defines the options used to create the mesh
  61800. * @param scene defines the hosting scene
  61801. * @returns the lathe mesh
  61802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61803. */
  61804. static CreateLathe(name: string, options: {
  61805. shape: Vector3[];
  61806. radius?: number;
  61807. tessellation?: number;
  61808. clip?: number;
  61809. arc?: number;
  61810. closed?: boolean;
  61811. updatable?: boolean;
  61812. sideOrientation?: number;
  61813. frontUVs?: Vector4;
  61814. backUVs?: Vector4;
  61815. cap?: number;
  61816. invertUV?: boolean;
  61817. }, scene?: Nullable<Scene>): Mesh;
  61818. /**
  61819. * Creates a tiled plane mesh
  61820. * * You can set a limited pattern arrangement with the tiles
  61821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61822. * * 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
  61823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61824. * @param name defines the name of the mesh
  61825. * @param options defines the options used to create the mesh
  61826. * @param scene defines the hosting scene
  61827. * @returns the plane mesh
  61828. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61829. */
  61830. static CreateTiledPlane(name: string, options: {
  61831. pattern?: number;
  61832. tileSize?: number;
  61833. tileWidth?: number;
  61834. tileHeight?: number;
  61835. size?: number;
  61836. width?: number;
  61837. height?: number;
  61838. alignHorizontal?: number;
  61839. alignVertical?: number;
  61840. sideOrientation?: number;
  61841. frontUVs?: Vector4;
  61842. backUVs?: Vector4;
  61843. updatable?: boolean;
  61844. }, scene?: Nullable<Scene>): Mesh;
  61845. /**
  61846. * Creates a plane mesh
  61847. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61848. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61849. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61851. * * 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
  61852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61853. * @param name defines the name of the mesh
  61854. * @param options defines the options used to create the mesh
  61855. * @param scene defines the hosting scene
  61856. * @returns the plane mesh
  61857. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61858. */
  61859. static CreatePlane(name: string, options: {
  61860. size?: number;
  61861. width?: number;
  61862. height?: number;
  61863. sideOrientation?: number;
  61864. frontUVs?: Vector4;
  61865. backUVs?: Vector4;
  61866. updatable?: boolean;
  61867. sourcePlane?: Plane;
  61868. }, scene?: Nullable<Scene>): Mesh;
  61869. /**
  61870. * Creates a ground mesh
  61871. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61872. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61874. * @param name defines the name of the mesh
  61875. * @param options defines the options used to create the mesh
  61876. * @param scene defines the hosting scene
  61877. * @returns the ground mesh
  61878. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61879. */
  61880. static CreateGround(name: string, options: {
  61881. width?: number;
  61882. height?: number;
  61883. subdivisions?: number;
  61884. subdivisionsX?: number;
  61885. subdivisionsY?: number;
  61886. updatable?: boolean;
  61887. }, scene?: Nullable<Scene>): Mesh;
  61888. /**
  61889. * Creates a tiled ground mesh
  61890. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61891. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61892. * * 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
  61893. * * 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
  61894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61895. * @param name defines the name of the mesh
  61896. * @param options defines the options used to create the mesh
  61897. * @param scene defines the hosting scene
  61898. * @returns the tiled ground mesh
  61899. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61900. */
  61901. static CreateTiledGround(name: string, options: {
  61902. xmin: number;
  61903. zmin: number;
  61904. xmax: number;
  61905. zmax: number;
  61906. subdivisions?: {
  61907. w: number;
  61908. h: number;
  61909. };
  61910. precision?: {
  61911. w: number;
  61912. h: number;
  61913. };
  61914. updatable?: boolean;
  61915. }, scene?: Nullable<Scene>): Mesh;
  61916. /**
  61917. * Creates a ground mesh from a height map
  61918. * * The parameter `url` sets the URL of the height map image resource.
  61919. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61920. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61921. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61922. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61923. * * 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.
  61924. * * 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).
  61925. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61927. * @param name defines the name of the mesh
  61928. * @param url defines the url to the height map
  61929. * @param options defines the options used to create the mesh
  61930. * @param scene defines the hosting scene
  61931. * @returns the ground mesh
  61932. * @see https://doc.babylonjs.com/babylon101/height_map
  61933. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61934. */
  61935. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61936. width?: number;
  61937. height?: number;
  61938. subdivisions?: number;
  61939. minHeight?: number;
  61940. maxHeight?: number;
  61941. colorFilter?: Color3;
  61942. alphaFilter?: number;
  61943. updatable?: boolean;
  61944. onReady?: (mesh: GroundMesh) => void;
  61945. }, scene?: Nullable<Scene>): GroundMesh;
  61946. /**
  61947. * Creates a polygon mesh
  61948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61949. * * 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
  61950. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61952. * * 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)
  61953. * * Remember you can only change the shape positions, not their number when updating a polygon
  61954. * @param name defines the name of the mesh
  61955. * @param options defines the options used to create the mesh
  61956. * @param scene defines the hosting scene
  61957. * @param earcutInjection can be used to inject your own earcut reference
  61958. * @returns the polygon mesh
  61959. */
  61960. static CreatePolygon(name: string, options: {
  61961. shape: Vector3[];
  61962. holes?: Vector3[][];
  61963. depth?: number;
  61964. faceUV?: Vector4[];
  61965. faceColors?: Color4[];
  61966. updatable?: boolean;
  61967. sideOrientation?: number;
  61968. frontUVs?: Vector4;
  61969. backUVs?: Vector4;
  61970. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61971. /**
  61972. * Creates an extruded polygon mesh, with depth in the Y direction.
  61973. * * 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)
  61974. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61975. * @param name defines the name of the mesh
  61976. * @param options defines the options used to create the mesh
  61977. * @param scene defines the hosting scene
  61978. * @param earcutInjection can be used to inject your own earcut reference
  61979. * @returns the polygon mesh
  61980. */
  61981. static ExtrudePolygon(name: string, options: {
  61982. shape: Vector3[];
  61983. holes?: Vector3[][];
  61984. depth?: number;
  61985. faceUV?: Vector4[];
  61986. faceColors?: Color4[];
  61987. updatable?: boolean;
  61988. sideOrientation?: number;
  61989. frontUVs?: Vector4;
  61990. backUVs?: Vector4;
  61991. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61992. /**
  61993. * Creates a tube mesh.
  61994. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61995. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61996. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61997. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61998. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61999. * * 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)
  62000. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62001. * * 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
  62002. * * 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
  62003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62004. * * 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
  62005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62007. * @param name defines the name of the mesh
  62008. * @param options defines the options used to create the mesh
  62009. * @param scene defines the hosting scene
  62010. * @returns the tube mesh
  62011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62012. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62013. */
  62014. static CreateTube(name: string, options: {
  62015. path: Vector3[];
  62016. radius?: number;
  62017. tessellation?: number;
  62018. radiusFunction?: {
  62019. (i: number, distance: number): number;
  62020. };
  62021. cap?: number;
  62022. arc?: number;
  62023. updatable?: boolean;
  62024. sideOrientation?: number;
  62025. frontUVs?: Vector4;
  62026. backUVs?: Vector4;
  62027. instance?: Mesh;
  62028. invertUV?: boolean;
  62029. }, scene?: Nullable<Scene>): Mesh;
  62030. /**
  62031. * Creates a polyhedron mesh
  62032. * * 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
  62033. * * The parameter `size` (positive float, default 1) sets the polygon size
  62034. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62035. * * 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`
  62036. * * 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
  62037. * * 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)`)
  62038. * * 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
  62039. * * 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
  62040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62041. * * 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
  62042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62043. * @param name defines the name of the mesh
  62044. * @param options defines the options used to create the mesh
  62045. * @param scene defines the hosting scene
  62046. * @returns the polyhedron mesh
  62047. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62048. */
  62049. static CreatePolyhedron(name: string, options: {
  62050. type?: number;
  62051. size?: number;
  62052. sizeX?: number;
  62053. sizeY?: number;
  62054. sizeZ?: number;
  62055. custom?: any;
  62056. faceUV?: Vector4[];
  62057. faceColors?: Color4[];
  62058. flat?: boolean;
  62059. updatable?: boolean;
  62060. sideOrientation?: number;
  62061. frontUVs?: Vector4;
  62062. backUVs?: Vector4;
  62063. }, scene?: Nullable<Scene>): Mesh;
  62064. /**
  62065. * Creates a decal mesh.
  62066. * 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
  62067. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62068. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62069. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62070. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62071. * @param name defines the name of the mesh
  62072. * @param sourceMesh defines the mesh where the decal must be applied
  62073. * @param options defines the options used to create the mesh
  62074. * @param scene defines the hosting scene
  62075. * @returns the decal mesh
  62076. * @see https://doc.babylonjs.com/how_to/decals
  62077. */
  62078. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62079. position?: Vector3;
  62080. normal?: Vector3;
  62081. size?: Vector3;
  62082. angle?: number;
  62083. }): Mesh;
  62084. }
  62085. }
  62086. declare module BABYLON {
  62087. /**
  62088. * A simplifier interface for future simplification implementations
  62089. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62090. */
  62091. export interface ISimplifier {
  62092. /**
  62093. * Simplification of a given mesh according to the given settings.
  62094. * Since this requires computation, it is assumed that the function runs async.
  62095. * @param settings The settings of the simplification, including quality and distance
  62096. * @param successCallback A callback that will be called after the mesh was simplified.
  62097. * @param errorCallback in case of an error, this callback will be called. optional.
  62098. */
  62099. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62100. }
  62101. /**
  62102. * Expected simplification settings.
  62103. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62104. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62105. */
  62106. export interface ISimplificationSettings {
  62107. /**
  62108. * Gets or sets the expected quality
  62109. */
  62110. quality: number;
  62111. /**
  62112. * Gets or sets the distance when this optimized version should be used
  62113. */
  62114. distance: number;
  62115. /**
  62116. * Gets an already optimized mesh
  62117. */
  62118. optimizeMesh?: boolean;
  62119. }
  62120. /**
  62121. * Class used to specify simplification options
  62122. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62123. */
  62124. export class SimplificationSettings implements ISimplificationSettings {
  62125. /** expected quality */
  62126. quality: number;
  62127. /** distance when this optimized version should be used */
  62128. distance: number;
  62129. /** already optimized mesh */
  62130. optimizeMesh?: boolean | undefined;
  62131. /**
  62132. * Creates a SimplificationSettings
  62133. * @param quality expected quality
  62134. * @param distance distance when this optimized version should be used
  62135. * @param optimizeMesh already optimized mesh
  62136. */
  62137. constructor(
  62138. /** expected quality */
  62139. quality: number,
  62140. /** distance when this optimized version should be used */
  62141. distance: number,
  62142. /** already optimized mesh */
  62143. optimizeMesh?: boolean | undefined);
  62144. }
  62145. /**
  62146. * Interface used to define a simplification task
  62147. */
  62148. export interface ISimplificationTask {
  62149. /**
  62150. * Array of settings
  62151. */
  62152. settings: Array<ISimplificationSettings>;
  62153. /**
  62154. * Simplification type
  62155. */
  62156. simplificationType: SimplificationType;
  62157. /**
  62158. * Mesh to simplify
  62159. */
  62160. mesh: Mesh;
  62161. /**
  62162. * Callback called on success
  62163. */
  62164. successCallback?: () => void;
  62165. /**
  62166. * Defines if parallel processing can be used
  62167. */
  62168. parallelProcessing: boolean;
  62169. }
  62170. /**
  62171. * Queue used to order the simplification tasks
  62172. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62173. */
  62174. export class SimplificationQueue {
  62175. private _simplificationArray;
  62176. /**
  62177. * Gets a boolean indicating that the process is still running
  62178. */
  62179. running: boolean;
  62180. /**
  62181. * Creates a new queue
  62182. */
  62183. constructor();
  62184. /**
  62185. * Adds a new simplification task
  62186. * @param task defines a task to add
  62187. */
  62188. addTask(task: ISimplificationTask): void;
  62189. /**
  62190. * Execute next task
  62191. */
  62192. executeNext(): void;
  62193. /**
  62194. * Execute a simplification task
  62195. * @param task defines the task to run
  62196. */
  62197. runSimplification(task: ISimplificationTask): void;
  62198. private getSimplifier;
  62199. }
  62200. /**
  62201. * The implemented types of simplification
  62202. * At the moment only Quadratic Error Decimation is implemented
  62203. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62204. */
  62205. export enum SimplificationType {
  62206. /** Quadratic error decimation */
  62207. QUADRATIC = 0
  62208. }
  62209. /**
  62210. * An implementation of the Quadratic Error simplification algorithm.
  62211. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62212. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62213. * @author RaananW
  62214. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62215. */
  62216. export class QuadraticErrorSimplification implements ISimplifier {
  62217. private _mesh;
  62218. private triangles;
  62219. private vertices;
  62220. private references;
  62221. private _reconstructedMesh;
  62222. /** Gets or sets the number pf sync interations */
  62223. syncIterations: number;
  62224. /** Gets or sets the aggressiveness of the simplifier */
  62225. aggressiveness: number;
  62226. /** Gets or sets the number of allowed iterations for decimation */
  62227. decimationIterations: number;
  62228. /** Gets or sets the espilon to use for bounding box computation */
  62229. boundingBoxEpsilon: number;
  62230. /**
  62231. * Creates a new QuadraticErrorSimplification
  62232. * @param _mesh defines the target mesh
  62233. */
  62234. constructor(_mesh: Mesh);
  62235. /**
  62236. * Simplification of a given mesh according to the given settings.
  62237. * Since this requires computation, it is assumed that the function runs async.
  62238. * @param settings The settings of the simplification, including quality and distance
  62239. * @param successCallback A callback that will be called after the mesh was simplified.
  62240. */
  62241. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62242. private runDecimation;
  62243. private initWithMesh;
  62244. private init;
  62245. private reconstructMesh;
  62246. private initDecimatedMesh;
  62247. private isFlipped;
  62248. private updateTriangles;
  62249. private identifyBorder;
  62250. private updateMesh;
  62251. private vertexError;
  62252. private calculateError;
  62253. }
  62254. }
  62255. declare module BABYLON {
  62256. interface Scene {
  62257. /** @hidden (Backing field) */
  62258. _simplificationQueue: SimplificationQueue;
  62259. /**
  62260. * Gets or sets the simplification queue attached to the scene
  62261. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62262. */
  62263. simplificationQueue: SimplificationQueue;
  62264. }
  62265. interface Mesh {
  62266. /**
  62267. * Simplify the mesh according to the given array of settings.
  62268. * Function will return immediately and will simplify async
  62269. * @param settings a collection of simplification settings
  62270. * @param parallelProcessing should all levels calculate parallel or one after the other
  62271. * @param simplificationType the type of simplification to run
  62272. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62273. * @returns the current mesh
  62274. */
  62275. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62276. }
  62277. /**
  62278. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62279. * created in a scene
  62280. */
  62281. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62282. /**
  62283. * The component name helpfull to identify the component in the list of scene components.
  62284. */
  62285. readonly name: string;
  62286. /**
  62287. * The scene the component belongs to.
  62288. */
  62289. scene: Scene;
  62290. /**
  62291. * Creates a new instance of the component for the given scene
  62292. * @param scene Defines the scene to register the component in
  62293. */
  62294. constructor(scene: Scene);
  62295. /**
  62296. * Registers the component in a given scene
  62297. */
  62298. register(): void;
  62299. /**
  62300. * Rebuilds the elements related to this component in case of
  62301. * context lost for instance.
  62302. */
  62303. rebuild(): void;
  62304. /**
  62305. * Disposes the component and the associated ressources
  62306. */
  62307. dispose(): void;
  62308. private _beforeCameraUpdate;
  62309. }
  62310. }
  62311. declare module BABYLON {
  62312. /**
  62313. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62314. */
  62315. export interface INavigationEnginePlugin {
  62316. /**
  62317. * plugin name
  62318. */
  62319. name: string;
  62320. /**
  62321. * Creates a navigation mesh
  62322. * @param meshes array of all the geometry used to compute the navigatio mesh
  62323. * @param parameters bunch of parameters used to filter geometry
  62324. */
  62325. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62326. /**
  62327. * Create a navigation mesh debug mesh
  62328. * @param scene is where the mesh will be added
  62329. * @returns debug display mesh
  62330. */
  62331. createDebugNavMesh(scene: Scene): Mesh;
  62332. /**
  62333. * Get a navigation mesh constrained position, closest to the parameter position
  62334. * @param position world position
  62335. * @returns the closest point to position constrained by the navigation mesh
  62336. */
  62337. getClosestPoint(position: Vector3): Vector3;
  62338. /**
  62339. * Get a navigation mesh constrained position, closest to the parameter position
  62340. * @param position world position
  62341. * @param result output the closest point to position constrained by the navigation mesh
  62342. */
  62343. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62344. /**
  62345. * Get a navigation mesh constrained position, within a particular radius
  62346. * @param position world position
  62347. * @param maxRadius the maximum distance to the constrained world position
  62348. * @returns the closest point to position constrained by the navigation mesh
  62349. */
  62350. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62351. /**
  62352. * Get a navigation mesh constrained position, within a particular radius
  62353. * @param position world position
  62354. * @param maxRadius the maximum distance to the constrained world position
  62355. * @param result output the closest point to position constrained by the navigation mesh
  62356. */
  62357. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62358. /**
  62359. * Compute the final position from a segment made of destination-position
  62360. * @param position world position
  62361. * @param destination world position
  62362. * @returns the resulting point along the navmesh
  62363. */
  62364. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62365. /**
  62366. * Compute the final position from a segment made of destination-position
  62367. * @param position world position
  62368. * @param destination world position
  62369. * @param result output the resulting point along the navmesh
  62370. */
  62371. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62372. /**
  62373. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62374. * @param start world position
  62375. * @param end world position
  62376. * @returns array containing world position composing the path
  62377. */
  62378. computePath(start: Vector3, end: Vector3): Vector3[];
  62379. /**
  62380. * If this plugin is supported
  62381. * @returns true if plugin is supported
  62382. */
  62383. isSupported(): boolean;
  62384. /**
  62385. * Create a new Crowd so you can add agents
  62386. * @param maxAgents the maximum agent count in the crowd
  62387. * @param maxAgentRadius the maximum radius an agent can have
  62388. * @param scene to attach the crowd to
  62389. * @returns the crowd you can add agents to
  62390. */
  62391. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62392. /**
  62393. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62394. * The queries will try to find a solution within those bounds
  62395. * default is (1,1,1)
  62396. * @param extent x,y,z value that define the extent around the queries point of reference
  62397. */
  62398. setDefaultQueryExtent(extent: Vector3): void;
  62399. /**
  62400. * Get the Bounding box extent specified by setDefaultQueryExtent
  62401. * @returns the box extent values
  62402. */
  62403. getDefaultQueryExtent(): Vector3;
  62404. /**
  62405. * build the navmesh from a previously saved state using getNavmeshData
  62406. * @param data the Uint8Array returned by getNavmeshData
  62407. */
  62408. buildFromNavmeshData(data: Uint8Array): void;
  62409. /**
  62410. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62411. * @returns data the Uint8Array that can be saved and reused
  62412. */
  62413. getNavmeshData(): Uint8Array;
  62414. /**
  62415. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62416. * @param result output the box extent values
  62417. */
  62418. getDefaultQueryExtentToRef(result: Vector3): void;
  62419. /**
  62420. * Release all resources
  62421. */
  62422. dispose(): void;
  62423. }
  62424. /**
  62425. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62426. */
  62427. export interface ICrowd {
  62428. /**
  62429. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62430. * You can attach anything to that node. The node position is updated in the scene update tick.
  62431. * @param pos world position that will be constrained by the navigation mesh
  62432. * @param parameters agent parameters
  62433. * @param transform hooked to the agent that will be update by the scene
  62434. * @returns agent index
  62435. */
  62436. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62437. /**
  62438. * Returns the agent position in world space
  62439. * @param index agent index returned by addAgent
  62440. * @returns world space position
  62441. */
  62442. getAgentPosition(index: number): Vector3;
  62443. /**
  62444. * Gets the agent position result in world space
  62445. * @param index agent index returned by addAgent
  62446. * @param result output world space position
  62447. */
  62448. getAgentPositionToRef(index: number, result: Vector3): void;
  62449. /**
  62450. * Gets the agent velocity in world space
  62451. * @param index agent index returned by addAgent
  62452. * @returns world space velocity
  62453. */
  62454. getAgentVelocity(index: number): Vector3;
  62455. /**
  62456. * Gets the agent velocity result in world space
  62457. * @param index agent index returned by addAgent
  62458. * @param result output world space velocity
  62459. */
  62460. getAgentVelocityToRef(index: number, result: Vector3): void;
  62461. /**
  62462. * remove a particular agent previously created
  62463. * @param index agent index returned by addAgent
  62464. */
  62465. removeAgent(index: number): void;
  62466. /**
  62467. * get the list of all agents attached to this crowd
  62468. * @returns list of agent indices
  62469. */
  62470. getAgents(): number[];
  62471. /**
  62472. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62473. * @param deltaTime in seconds
  62474. */
  62475. update(deltaTime: number): void;
  62476. /**
  62477. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62478. * @param index agent index returned by addAgent
  62479. * @param destination targeted world position
  62480. */
  62481. agentGoto(index: number, destination: Vector3): void;
  62482. /**
  62483. * Teleport the agent to a new position
  62484. * @param index agent index returned by addAgent
  62485. * @param destination targeted world position
  62486. */
  62487. agentTeleport(index: number, destination: Vector3): void;
  62488. /**
  62489. * Update agent parameters
  62490. * @param index agent index returned by addAgent
  62491. * @param parameters agent parameters
  62492. */
  62493. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62494. /**
  62495. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62496. * The queries will try to find a solution within those bounds
  62497. * default is (1,1,1)
  62498. * @param extent x,y,z value that define the extent around the queries point of reference
  62499. */
  62500. setDefaultQueryExtent(extent: Vector3): void;
  62501. /**
  62502. * Get the Bounding box extent specified by setDefaultQueryExtent
  62503. * @returns the box extent values
  62504. */
  62505. getDefaultQueryExtent(): Vector3;
  62506. /**
  62507. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62508. * @param result output the box extent values
  62509. */
  62510. getDefaultQueryExtentToRef(result: Vector3): void;
  62511. /**
  62512. * Release all resources
  62513. */
  62514. dispose(): void;
  62515. }
  62516. /**
  62517. * Configures an agent
  62518. */
  62519. export interface IAgentParameters {
  62520. /**
  62521. * Agent radius. [Limit: >= 0]
  62522. */
  62523. radius: number;
  62524. /**
  62525. * Agent height. [Limit: > 0]
  62526. */
  62527. height: number;
  62528. /**
  62529. * Maximum allowed acceleration. [Limit: >= 0]
  62530. */
  62531. maxAcceleration: number;
  62532. /**
  62533. * Maximum allowed speed. [Limit: >= 0]
  62534. */
  62535. maxSpeed: number;
  62536. /**
  62537. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62538. */
  62539. collisionQueryRange: number;
  62540. /**
  62541. * The path visibility optimization range. [Limit: > 0]
  62542. */
  62543. pathOptimizationRange: number;
  62544. /**
  62545. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62546. */
  62547. separationWeight: number;
  62548. }
  62549. /**
  62550. * Configures the navigation mesh creation
  62551. */
  62552. export interface INavMeshParameters {
  62553. /**
  62554. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62555. */
  62556. cs: number;
  62557. /**
  62558. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62559. */
  62560. ch: number;
  62561. /**
  62562. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62563. */
  62564. walkableSlopeAngle: number;
  62565. /**
  62566. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62567. * be considered walkable. [Limit: >= 3] [Units: vx]
  62568. */
  62569. walkableHeight: number;
  62570. /**
  62571. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62572. */
  62573. walkableClimb: number;
  62574. /**
  62575. * The distance to erode/shrink the walkable area of the heightfield away from
  62576. * obstructions. [Limit: >=0] [Units: vx]
  62577. */
  62578. walkableRadius: number;
  62579. /**
  62580. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62581. */
  62582. maxEdgeLen: number;
  62583. /**
  62584. * The maximum distance a simplfied contour's border edges should deviate
  62585. * the original raw contour. [Limit: >=0] [Units: vx]
  62586. */
  62587. maxSimplificationError: number;
  62588. /**
  62589. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62590. */
  62591. minRegionArea: number;
  62592. /**
  62593. * Any regions with a span count smaller than this value will, if possible,
  62594. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62595. */
  62596. mergeRegionArea: number;
  62597. /**
  62598. * The maximum number of vertices allowed for polygons generated during the
  62599. * contour to polygon conversion process. [Limit: >= 3]
  62600. */
  62601. maxVertsPerPoly: number;
  62602. /**
  62603. * Sets the sampling distance to use when generating the detail mesh.
  62604. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62605. */
  62606. detailSampleDist: number;
  62607. /**
  62608. * The maximum distance the detail mesh surface should deviate from heightfield
  62609. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62610. */
  62611. detailSampleMaxError: number;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /**
  62616. * RecastJS navigation plugin
  62617. */
  62618. export class RecastJSPlugin implements INavigationEnginePlugin {
  62619. /**
  62620. * Reference to the Recast library
  62621. */
  62622. bjsRECAST: any;
  62623. /**
  62624. * plugin name
  62625. */
  62626. name: string;
  62627. /**
  62628. * the first navmesh created. We might extend this to support multiple navmeshes
  62629. */
  62630. navMesh: any;
  62631. /**
  62632. * Initializes the recastJS plugin
  62633. * @param recastInjection can be used to inject your own recast reference
  62634. */
  62635. constructor(recastInjection?: any);
  62636. /**
  62637. * Creates a navigation mesh
  62638. * @param meshes array of all the geometry used to compute the navigatio mesh
  62639. * @param parameters bunch of parameters used to filter geometry
  62640. */
  62641. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62642. /**
  62643. * Create a navigation mesh debug mesh
  62644. * @param scene is where the mesh will be added
  62645. * @returns debug display mesh
  62646. */
  62647. createDebugNavMesh(scene: Scene): Mesh;
  62648. /**
  62649. * Get a navigation mesh constrained position, closest to the parameter position
  62650. * @param position world position
  62651. * @returns the closest point to position constrained by the navigation mesh
  62652. */
  62653. getClosestPoint(position: Vector3): Vector3;
  62654. /**
  62655. * Get a navigation mesh constrained position, closest to the parameter position
  62656. * @param position world position
  62657. * @param result output the closest point to position constrained by the navigation mesh
  62658. */
  62659. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62660. /**
  62661. * Get a navigation mesh constrained position, within a particular radius
  62662. * @param position world position
  62663. * @param maxRadius the maximum distance to the constrained world position
  62664. * @returns the closest point to position constrained by the navigation mesh
  62665. */
  62666. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62667. /**
  62668. * Get a navigation mesh constrained position, within a particular radius
  62669. * @param position world position
  62670. * @param maxRadius the maximum distance to the constrained world position
  62671. * @param result output the closest point to position constrained by the navigation mesh
  62672. */
  62673. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62674. /**
  62675. * Compute the final position from a segment made of destination-position
  62676. * @param position world position
  62677. * @param destination world position
  62678. * @returns the resulting point along the navmesh
  62679. */
  62680. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62681. /**
  62682. * Compute the final position from a segment made of destination-position
  62683. * @param position world position
  62684. * @param destination world position
  62685. * @param result output the resulting point along the navmesh
  62686. */
  62687. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62688. /**
  62689. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62690. * @param start world position
  62691. * @param end world position
  62692. * @returns array containing world position composing the path
  62693. */
  62694. computePath(start: Vector3, end: Vector3): Vector3[];
  62695. /**
  62696. * Create a new Crowd so you can add agents
  62697. * @param maxAgents the maximum agent count in the crowd
  62698. * @param maxAgentRadius the maximum radius an agent can have
  62699. * @param scene to attach the crowd to
  62700. * @returns the crowd you can add agents to
  62701. */
  62702. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62703. /**
  62704. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62705. * The queries will try to find a solution within those bounds
  62706. * default is (1,1,1)
  62707. * @param extent x,y,z value that define the extent around the queries point of reference
  62708. */
  62709. setDefaultQueryExtent(extent: Vector3): void;
  62710. /**
  62711. * Get the Bounding box extent specified by setDefaultQueryExtent
  62712. * @returns the box extent values
  62713. */
  62714. getDefaultQueryExtent(): Vector3;
  62715. /**
  62716. * build the navmesh from a previously saved state using getNavmeshData
  62717. * @param data the Uint8Array returned by getNavmeshData
  62718. */
  62719. buildFromNavmeshData(data: Uint8Array): void;
  62720. /**
  62721. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62722. * @returns data the Uint8Array that can be saved and reused
  62723. */
  62724. getNavmeshData(): Uint8Array;
  62725. /**
  62726. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62727. * @param result output the box extent values
  62728. */
  62729. getDefaultQueryExtentToRef(result: Vector3): void;
  62730. /**
  62731. * Disposes
  62732. */
  62733. dispose(): void;
  62734. /**
  62735. * If this plugin is supported
  62736. * @returns true if plugin is supported
  62737. */
  62738. isSupported(): boolean;
  62739. }
  62740. /**
  62741. * Recast detour crowd implementation
  62742. */
  62743. export class RecastJSCrowd implements ICrowd {
  62744. /**
  62745. * Recast/detour plugin
  62746. */
  62747. bjsRECASTPlugin: RecastJSPlugin;
  62748. /**
  62749. * Link to the detour crowd
  62750. */
  62751. recastCrowd: any;
  62752. /**
  62753. * One transform per agent
  62754. */
  62755. transforms: TransformNode[];
  62756. /**
  62757. * All agents created
  62758. */
  62759. agents: number[];
  62760. /**
  62761. * Link to the scene is kept to unregister the crowd from the scene
  62762. */
  62763. private _scene;
  62764. /**
  62765. * Observer for crowd updates
  62766. */
  62767. private _onBeforeAnimationsObserver;
  62768. /**
  62769. * Constructor
  62770. * @param plugin recastJS plugin
  62771. * @param maxAgents the maximum agent count in the crowd
  62772. * @param maxAgentRadius the maximum radius an agent can have
  62773. * @param scene to attach the crowd to
  62774. * @returns the crowd you can add agents to
  62775. */
  62776. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62777. /**
  62778. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62779. * You can attach anything to that node. The node position is updated in the scene update tick.
  62780. * @param pos world position that will be constrained by the navigation mesh
  62781. * @param parameters agent parameters
  62782. * @param transform hooked to the agent that will be update by the scene
  62783. * @returns agent index
  62784. */
  62785. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62786. /**
  62787. * Returns the agent position in world space
  62788. * @param index agent index returned by addAgent
  62789. * @returns world space position
  62790. */
  62791. getAgentPosition(index: number): Vector3;
  62792. /**
  62793. * Returns the agent position result in world space
  62794. * @param index agent index returned by addAgent
  62795. * @param result output world space position
  62796. */
  62797. getAgentPositionToRef(index: number, result: Vector3): void;
  62798. /**
  62799. * Returns the agent velocity in world space
  62800. * @param index agent index returned by addAgent
  62801. * @returns world space velocity
  62802. */
  62803. getAgentVelocity(index: number): Vector3;
  62804. /**
  62805. * Returns the agent velocity result in world space
  62806. * @param index agent index returned by addAgent
  62807. * @param result output world space velocity
  62808. */
  62809. getAgentVelocityToRef(index: number, result: Vector3): void;
  62810. /**
  62811. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62812. * @param index agent index returned by addAgent
  62813. * @param destination targeted world position
  62814. */
  62815. agentGoto(index: number, destination: Vector3): void;
  62816. /**
  62817. * Teleport the agent to a new position
  62818. * @param index agent index returned by addAgent
  62819. * @param destination targeted world position
  62820. */
  62821. agentTeleport(index: number, destination: Vector3): void;
  62822. /**
  62823. * Update agent parameters
  62824. * @param index agent index returned by addAgent
  62825. * @param parameters agent parameters
  62826. */
  62827. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62828. /**
  62829. * remove a particular agent previously created
  62830. * @param index agent index returned by addAgent
  62831. */
  62832. removeAgent(index: number): void;
  62833. /**
  62834. * get the list of all agents attached to this crowd
  62835. * @returns list of agent indices
  62836. */
  62837. getAgents(): number[];
  62838. /**
  62839. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62840. * @param deltaTime in seconds
  62841. */
  62842. update(deltaTime: number): void;
  62843. /**
  62844. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62845. * The queries will try to find a solution within those bounds
  62846. * default is (1,1,1)
  62847. * @param extent x,y,z value that define the extent around the queries point of reference
  62848. */
  62849. setDefaultQueryExtent(extent: Vector3): void;
  62850. /**
  62851. * Get the Bounding box extent specified by setDefaultQueryExtent
  62852. * @returns the box extent values
  62853. */
  62854. getDefaultQueryExtent(): Vector3;
  62855. /**
  62856. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62857. * @param result output the box extent values
  62858. */
  62859. getDefaultQueryExtentToRef(result: Vector3): void;
  62860. /**
  62861. * Release all resources
  62862. */
  62863. dispose(): void;
  62864. }
  62865. }
  62866. declare module BABYLON {
  62867. /**
  62868. * Class used to enable access to IndexedDB
  62869. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62870. */
  62871. export class Database implements IOfflineProvider {
  62872. private _callbackManifestChecked;
  62873. private _currentSceneUrl;
  62874. private _db;
  62875. private _enableSceneOffline;
  62876. private _enableTexturesOffline;
  62877. private _manifestVersionFound;
  62878. private _mustUpdateRessources;
  62879. private _hasReachedQuota;
  62880. private _isSupported;
  62881. private _idbFactory;
  62882. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62883. private static IsUASupportingBlobStorage;
  62884. /**
  62885. * Gets a boolean indicating if Database storate is enabled (off by default)
  62886. */
  62887. static IDBStorageEnabled: boolean;
  62888. /**
  62889. * Gets a boolean indicating if scene must be saved in the database
  62890. */
  62891. get enableSceneOffline(): boolean;
  62892. /**
  62893. * Gets a boolean indicating if textures must be saved in the database
  62894. */
  62895. get enableTexturesOffline(): boolean;
  62896. /**
  62897. * Creates a new Database
  62898. * @param urlToScene defines the url to load the scene
  62899. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62900. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62901. */
  62902. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62903. private static _ParseURL;
  62904. private static _ReturnFullUrlLocation;
  62905. private _checkManifestFile;
  62906. /**
  62907. * Open the database and make it available
  62908. * @param successCallback defines the callback to call on success
  62909. * @param errorCallback defines the callback to call on error
  62910. */
  62911. open(successCallback: () => void, errorCallback: () => void): void;
  62912. /**
  62913. * Loads an image from the database
  62914. * @param url defines the url to load from
  62915. * @param image defines the target DOM image
  62916. */
  62917. loadImage(url: string, image: HTMLImageElement): void;
  62918. private _loadImageFromDBAsync;
  62919. private _saveImageIntoDBAsync;
  62920. private _checkVersionFromDB;
  62921. private _loadVersionFromDBAsync;
  62922. private _saveVersionIntoDBAsync;
  62923. /**
  62924. * Loads a file from database
  62925. * @param url defines the URL to load from
  62926. * @param sceneLoaded defines a callback to call on success
  62927. * @param progressCallBack defines a callback to call when progress changed
  62928. * @param errorCallback defines a callback to call on error
  62929. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62930. */
  62931. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62932. private _loadFileAsync;
  62933. private _saveFileAsync;
  62934. /**
  62935. * Validates if xhr data is correct
  62936. * @param xhr defines the request to validate
  62937. * @param dataType defines the expected data type
  62938. * @returns true if data is correct
  62939. */
  62940. private static _ValidateXHRData;
  62941. }
  62942. }
  62943. declare module BABYLON {
  62944. /** @hidden */
  62945. export var gpuUpdateParticlesPixelShader: {
  62946. name: string;
  62947. shader: string;
  62948. };
  62949. }
  62950. declare module BABYLON {
  62951. /** @hidden */
  62952. export var gpuUpdateParticlesVertexShader: {
  62953. name: string;
  62954. shader: string;
  62955. };
  62956. }
  62957. declare module BABYLON {
  62958. /** @hidden */
  62959. export var clipPlaneFragmentDeclaration2: {
  62960. name: string;
  62961. shader: string;
  62962. };
  62963. }
  62964. declare module BABYLON {
  62965. /** @hidden */
  62966. export var gpuRenderParticlesPixelShader: {
  62967. name: string;
  62968. shader: string;
  62969. };
  62970. }
  62971. declare module BABYLON {
  62972. /** @hidden */
  62973. export var clipPlaneVertexDeclaration2: {
  62974. name: string;
  62975. shader: string;
  62976. };
  62977. }
  62978. declare module BABYLON {
  62979. /** @hidden */
  62980. export var gpuRenderParticlesVertexShader: {
  62981. name: string;
  62982. shader: string;
  62983. };
  62984. }
  62985. declare module BABYLON {
  62986. /**
  62987. * This represents a GPU particle system in Babylon
  62988. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62989. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62990. */
  62991. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62992. /**
  62993. * The layer mask we are rendering the particles through.
  62994. */
  62995. layerMask: number;
  62996. private _capacity;
  62997. private _activeCount;
  62998. private _currentActiveCount;
  62999. private _accumulatedCount;
  63000. private _renderEffect;
  63001. private _updateEffect;
  63002. private _buffer0;
  63003. private _buffer1;
  63004. private _spriteBuffer;
  63005. private _updateVAO;
  63006. private _renderVAO;
  63007. private _targetIndex;
  63008. private _sourceBuffer;
  63009. private _targetBuffer;
  63010. private _engine;
  63011. private _currentRenderId;
  63012. private _started;
  63013. private _stopped;
  63014. private _timeDelta;
  63015. private _randomTexture;
  63016. private _randomTexture2;
  63017. private _attributesStrideSize;
  63018. private _updateEffectOptions;
  63019. private _randomTextureSize;
  63020. private _actualFrame;
  63021. private readonly _rawTextureWidth;
  63022. /**
  63023. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63024. */
  63025. static get IsSupported(): boolean;
  63026. /**
  63027. * An event triggered when the system is disposed.
  63028. */
  63029. onDisposeObservable: Observable<GPUParticleSystem>;
  63030. /**
  63031. * Gets the maximum number of particles active at the same time.
  63032. * @returns The max number of active particles.
  63033. */
  63034. getCapacity(): number;
  63035. /**
  63036. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63037. * to override the particles.
  63038. */
  63039. forceDepthWrite: boolean;
  63040. /**
  63041. * Gets or set the number of active particles
  63042. */
  63043. get activeParticleCount(): number;
  63044. set activeParticleCount(value: number);
  63045. private _preWarmDone;
  63046. /**
  63047. * Specifies if the particles are updated in emitter local space or world space.
  63048. * This is always false for GPU particles
  63049. */
  63050. get isLocal(): boolean;
  63051. set isLocal(value: boolean);
  63052. /**
  63053. * Is this system ready to be used/rendered
  63054. * @return true if the system is ready
  63055. */
  63056. isReady(): boolean;
  63057. /**
  63058. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63059. * @returns True if it has been started, otherwise false.
  63060. */
  63061. isStarted(): boolean;
  63062. /**
  63063. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63064. * @returns True if it has been stopped, otherwise false.
  63065. */
  63066. isStopped(): boolean;
  63067. /**
  63068. * Gets a boolean indicating that the system is stopping
  63069. * @returns true if the system is currently stopping
  63070. */
  63071. isStopping(): boolean;
  63072. /**
  63073. * Gets the number of particles active at the same time.
  63074. * @returns The number of active particles.
  63075. */
  63076. getActiveCount(): number;
  63077. /**
  63078. * Starts the particle system and begins to emit
  63079. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63080. */
  63081. start(delay?: number): void;
  63082. /**
  63083. * Stops the particle system.
  63084. */
  63085. stop(): void;
  63086. /**
  63087. * Remove all active particles
  63088. */
  63089. reset(): void;
  63090. /**
  63091. * Returns the string "GPUParticleSystem"
  63092. * @returns a string containing the class name
  63093. */
  63094. getClassName(): string;
  63095. private _colorGradientsTexture;
  63096. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63097. /**
  63098. * Adds a new color gradient
  63099. * @param gradient defines the gradient to use (between 0 and 1)
  63100. * @param color1 defines the color to affect to the specified gradient
  63101. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63102. * @returns the current particle system
  63103. */
  63104. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63105. private _refreshColorGradient;
  63106. /** Force the system to rebuild all gradients */
  63107. forceRefreshGradients(): void;
  63108. /**
  63109. * Remove a specific color gradient
  63110. * @param gradient defines the gradient to remove
  63111. * @returns the current particle system
  63112. */
  63113. removeColorGradient(gradient: number): GPUParticleSystem;
  63114. private _angularSpeedGradientsTexture;
  63115. private _sizeGradientsTexture;
  63116. private _velocityGradientsTexture;
  63117. private _limitVelocityGradientsTexture;
  63118. private _dragGradientsTexture;
  63119. private _addFactorGradient;
  63120. /**
  63121. * Adds a new size gradient
  63122. * @param gradient defines the gradient to use (between 0 and 1)
  63123. * @param factor defines the size factor to affect to the specified gradient
  63124. * @returns the current particle system
  63125. */
  63126. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63127. /**
  63128. * Remove a specific size gradient
  63129. * @param gradient defines the gradient to remove
  63130. * @returns the current particle system
  63131. */
  63132. removeSizeGradient(gradient: number): GPUParticleSystem;
  63133. private _refreshFactorGradient;
  63134. /**
  63135. * Adds a new angular speed gradient
  63136. * @param gradient defines the gradient to use (between 0 and 1)
  63137. * @param factor defines the angular speed to affect to the specified gradient
  63138. * @returns the current particle system
  63139. */
  63140. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63141. /**
  63142. * Remove a specific angular speed gradient
  63143. * @param gradient defines the gradient to remove
  63144. * @returns the current particle system
  63145. */
  63146. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63147. /**
  63148. * Adds a new velocity gradient
  63149. * @param gradient defines the gradient to use (between 0 and 1)
  63150. * @param factor defines the velocity to affect to the specified gradient
  63151. * @returns the current particle system
  63152. */
  63153. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63154. /**
  63155. * Remove a specific velocity gradient
  63156. * @param gradient defines the gradient to remove
  63157. * @returns the current particle system
  63158. */
  63159. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63160. /**
  63161. * Adds a new limit velocity gradient
  63162. * @param gradient defines the gradient to use (between 0 and 1)
  63163. * @param factor defines the limit velocity value to affect to the specified gradient
  63164. * @returns the current particle system
  63165. */
  63166. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63167. /**
  63168. * Remove a specific limit velocity gradient
  63169. * @param gradient defines the gradient to remove
  63170. * @returns the current particle system
  63171. */
  63172. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63173. /**
  63174. * Adds a new drag gradient
  63175. * @param gradient defines the gradient to use (between 0 and 1)
  63176. * @param factor defines the drag value to affect to the specified gradient
  63177. * @returns the current particle system
  63178. */
  63179. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63180. /**
  63181. * Remove a specific drag gradient
  63182. * @param gradient defines the gradient to remove
  63183. * @returns the current particle system
  63184. */
  63185. removeDragGradient(gradient: number): GPUParticleSystem;
  63186. /**
  63187. * Not supported by GPUParticleSystem
  63188. * @param gradient defines the gradient to use (between 0 and 1)
  63189. * @param factor defines the emit rate value to affect to the specified gradient
  63190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63191. * @returns the current particle system
  63192. */
  63193. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63194. /**
  63195. * Not supported by GPUParticleSystem
  63196. * @param gradient defines the gradient to remove
  63197. * @returns the current particle system
  63198. */
  63199. removeEmitRateGradient(gradient: number): IParticleSystem;
  63200. /**
  63201. * Not supported by GPUParticleSystem
  63202. * @param gradient defines the gradient to use (between 0 and 1)
  63203. * @param factor defines the start size value to affect to the specified gradient
  63204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63205. * @returns the current particle system
  63206. */
  63207. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63208. /**
  63209. * Not supported by GPUParticleSystem
  63210. * @param gradient defines the gradient to remove
  63211. * @returns the current particle system
  63212. */
  63213. removeStartSizeGradient(gradient: number): IParticleSystem;
  63214. /**
  63215. * Not supported by GPUParticleSystem
  63216. * @param gradient defines the gradient to use (between 0 and 1)
  63217. * @param min defines the color remap minimal range
  63218. * @param max defines the color remap maximal range
  63219. * @returns the current particle system
  63220. */
  63221. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63222. /**
  63223. * Not supported by GPUParticleSystem
  63224. * @param gradient defines the gradient to remove
  63225. * @returns the current particle system
  63226. */
  63227. removeColorRemapGradient(): IParticleSystem;
  63228. /**
  63229. * Not supported by GPUParticleSystem
  63230. * @param gradient defines the gradient to use (between 0 and 1)
  63231. * @param min defines the alpha remap minimal range
  63232. * @param max defines the alpha remap maximal range
  63233. * @returns the current particle system
  63234. */
  63235. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63236. /**
  63237. * Not supported by GPUParticleSystem
  63238. * @param gradient defines the gradient to remove
  63239. * @returns the current particle system
  63240. */
  63241. removeAlphaRemapGradient(): IParticleSystem;
  63242. /**
  63243. * Not supported by GPUParticleSystem
  63244. * @param gradient defines the gradient to use (between 0 and 1)
  63245. * @param color defines the color to affect to the specified gradient
  63246. * @returns the current particle system
  63247. */
  63248. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63249. /**
  63250. * Not supported by GPUParticleSystem
  63251. * @param gradient defines the gradient to remove
  63252. * @returns the current particle system
  63253. */
  63254. removeRampGradient(): IParticleSystem;
  63255. /**
  63256. * Not supported by GPUParticleSystem
  63257. * @returns the list of ramp gradients
  63258. */
  63259. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63260. /**
  63261. * Not supported by GPUParticleSystem
  63262. * Gets or sets a boolean indicating that ramp gradients must be used
  63263. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63264. */
  63265. get useRampGradients(): boolean;
  63266. set useRampGradients(value: boolean);
  63267. /**
  63268. * Not supported by GPUParticleSystem
  63269. * @param gradient defines the gradient to use (between 0 and 1)
  63270. * @param factor defines the life time factor to affect to the specified gradient
  63271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63272. * @returns the current particle system
  63273. */
  63274. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63275. /**
  63276. * Not supported by GPUParticleSystem
  63277. * @param gradient defines the gradient to remove
  63278. * @returns the current particle system
  63279. */
  63280. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63281. /**
  63282. * Instantiates a GPU particle system.
  63283. * 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.
  63284. * @param name The name of the particle system
  63285. * @param options The options used to create the system
  63286. * @param scene The scene the particle system belongs to
  63287. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63288. */
  63289. constructor(name: string, options: Partial<{
  63290. capacity: number;
  63291. randomTextureSize: number;
  63292. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63293. protected _reset(): void;
  63294. private _createUpdateVAO;
  63295. private _createRenderVAO;
  63296. private _initialize;
  63297. /** @hidden */
  63298. _recreateUpdateEffect(): void;
  63299. /** @hidden */
  63300. _recreateRenderEffect(): void;
  63301. /**
  63302. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63303. * @param preWarm defines if we are in the pre-warmimg phase
  63304. */
  63305. animate(preWarm?: boolean): void;
  63306. private _createFactorGradientTexture;
  63307. private _createSizeGradientTexture;
  63308. private _createAngularSpeedGradientTexture;
  63309. private _createVelocityGradientTexture;
  63310. private _createLimitVelocityGradientTexture;
  63311. private _createDragGradientTexture;
  63312. private _createColorGradientTexture;
  63313. /**
  63314. * Renders the particle system in its current state
  63315. * @param preWarm defines if the system should only update the particles but not render them
  63316. * @returns the current number of particles
  63317. */
  63318. render(preWarm?: boolean): number;
  63319. /**
  63320. * Rebuilds the particle system
  63321. */
  63322. rebuild(): void;
  63323. private _releaseBuffers;
  63324. private _releaseVAOs;
  63325. /**
  63326. * Disposes the particle system and free the associated resources
  63327. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63328. */
  63329. dispose(disposeTexture?: boolean): void;
  63330. /**
  63331. * Clones the particle system.
  63332. * @param name The name of the cloned object
  63333. * @param newEmitter The new emitter to use
  63334. * @returns the cloned particle system
  63335. */
  63336. clone(name: string, newEmitter: any): GPUParticleSystem;
  63337. /**
  63338. * Serializes the particle system to a JSON object.
  63339. * @returns the JSON object
  63340. */
  63341. serialize(): any;
  63342. /**
  63343. * Parses a JSON object to create a GPU particle system.
  63344. * @param parsedParticleSystem The JSON object to parse
  63345. * @param scene The scene to create the particle system in
  63346. * @param rootUrl The root url to use to load external dependencies like texture
  63347. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63348. * @returns the parsed GPU particle system
  63349. */
  63350. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63351. }
  63352. }
  63353. declare module BABYLON {
  63354. /**
  63355. * Represents a set of particle systems working together to create a specific effect
  63356. */
  63357. export class ParticleSystemSet implements IDisposable {
  63358. /**
  63359. * Gets or sets base Assets URL
  63360. */
  63361. static BaseAssetsUrl: string;
  63362. private _emitterCreationOptions;
  63363. private _emitterNode;
  63364. /**
  63365. * Gets the particle system list
  63366. */
  63367. systems: IParticleSystem[];
  63368. /**
  63369. * Gets the emitter node used with this set
  63370. */
  63371. get emitterNode(): Nullable<TransformNode>;
  63372. /**
  63373. * Creates a new emitter mesh as a sphere
  63374. * @param options defines the options used to create the sphere
  63375. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63376. * @param scene defines the hosting scene
  63377. */
  63378. setEmitterAsSphere(options: {
  63379. diameter: number;
  63380. segments: number;
  63381. color: Color3;
  63382. }, renderingGroupId: number, scene: Scene): void;
  63383. /**
  63384. * Starts all particle systems of the set
  63385. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63386. */
  63387. start(emitter?: AbstractMesh): void;
  63388. /**
  63389. * Release all associated resources
  63390. */
  63391. dispose(): void;
  63392. /**
  63393. * Serialize the set into a JSON compatible object
  63394. * @returns a JSON compatible representation of the set
  63395. */
  63396. serialize(): any;
  63397. /**
  63398. * Parse a new ParticleSystemSet from a serialized source
  63399. * @param data defines a JSON compatible representation of the set
  63400. * @param scene defines the hosting scene
  63401. * @param gpu defines if we want GPU particles or CPU particles
  63402. * @returns a new ParticleSystemSet
  63403. */
  63404. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63405. }
  63406. }
  63407. declare module BABYLON {
  63408. /**
  63409. * This class is made for on one-liner static method to help creating particle system set.
  63410. */
  63411. export class ParticleHelper {
  63412. /**
  63413. * Gets or sets base Assets URL
  63414. */
  63415. static BaseAssetsUrl: string;
  63416. /** Define the Url to load snippets */
  63417. static SnippetUrl: string;
  63418. /**
  63419. * Create a default particle system that you can tweak
  63420. * @param emitter defines the emitter to use
  63421. * @param capacity defines the system capacity (default is 500 particles)
  63422. * @param scene defines the hosting scene
  63423. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63424. * @returns the new Particle system
  63425. */
  63426. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63427. /**
  63428. * This is the main static method (one-liner) of this helper to create different particle systems
  63429. * @param type This string represents the type to the particle system to create
  63430. * @param scene The scene where the particle system should live
  63431. * @param gpu If the system will use gpu
  63432. * @returns the ParticleSystemSet created
  63433. */
  63434. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63435. /**
  63436. * Static function used to export a particle system to a ParticleSystemSet variable.
  63437. * Please note that the emitter shape is not exported
  63438. * @param systems defines the particle systems to export
  63439. * @returns the created particle system set
  63440. */
  63441. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63442. /**
  63443. * Creates a node material from a snippet saved by the node material editor
  63444. * @param snippetId defines the snippet to load
  63445. * @param scene defines the hosting scene
  63446. * @param gpu If the system will use gpu
  63447. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63448. * @returns a promise that will resolve to the new node material
  63449. */
  63450. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63451. }
  63452. }
  63453. declare module BABYLON {
  63454. interface Engine {
  63455. /**
  63456. * Create an effect to use with particle systems.
  63457. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63458. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63459. * @param uniformsNames defines a list of attribute names
  63460. * @param samplers defines an array of string used to represent textures
  63461. * @param defines defines the string containing the defines to use to compile the shaders
  63462. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63463. * @param onCompiled defines a function to call when the effect creation is successful
  63464. * @param onError defines a function to call when the effect creation has failed
  63465. * @returns the new Effect
  63466. */
  63467. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63468. }
  63469. interface Mesh {
  63470. /**
  63471. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63472. * @returns an array of IParticleSystem
  63473. */
  63474. getEmittedParticleSystems(): IParticleSystem[];
  63475. /**
  63476. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63477. * @returns an array of IParticleSystem
  63478. */
  63479. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63480. }
  63481. /**
  63482. * @hidden
  63483. */
  63484. export var _IDoNeedToBeInTheBuild: number;
  63485. }
  63486. declare module BABYLON {
  63487. /** Defines the 4 color options */
  63488. export enum PointColor {
  63489. /** color value */
  63490. Color = 2,
  63491. /** uv value */
  63492. UV = 1,
  63493. /** random value */
  63494. Random = 0,
  63495. /** stated value */
  63496. Stated = 3
  63497. }
  63498. /**
  63499. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63500. * 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.
  63501. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63502. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63503. *
  63504. * Full documentation here : TO BE ENTERED
  63505. */
  63506. export class PointsCloudSystem implements IDisposable {
  63507. /**
  63508. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63509. * Example : var p = SPS.particles[i];
  63510. */
  63511. particles: CloudPoint[];
  63512. /**
  63513. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63514. */
  63515. nbParticles: number;
  63516. /**
  63517. * This a counter for your own usage. It's not set by any SPS functions.
  63518. */
  63519. counter: number;
  63520. /**
  63521. * The PCS name. This name is also given to the underlying mesh.
  63522. */
  63523. name: string;
  63524. /**
  63525. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63526. */
  63527. mesh: Mesh;
  63528. /**
  63529. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63530. * Please read :
  63531. */
  63532. vars: any;
  63533. /**
  63534. * @hidden
  63535. */
  63536. _size: number;
  63537. private _scene;
  63538. private _promises;
  63539. private _positions;
  63540. private _indices;
  63541. private _normals;
  63542. private _colors;
  63543. private _uvs;
  63544. private _indices32;
  63545. private _positions32;
  63546. private _colors32;
  63547. private _uvs32;
  63548. private _updatable;
  63549. private _isVisibilityBoxLocked;
  63550. private _alwaysVisible;
  63551. private _groups;
  63552. private _groupCounter;
  63553. private _computeParticleColor;
  63554. private _computeParticleTexture;
  63555. private _computeParticleRotation;
  63556. private _computeBoundingBox;
  63557. private _isReady;
  63558. /**
  63559. * Creates a PCS (Points Cloud System) object
  63560. * @param name (String) is the PCS name, this will be the underlying mesh name
  63561. * @param pointSize (number) is the size for each point
  63562. * @param scene (Scene) is the scene in which the PCS is added
  63563. * @param options defines the options of the PCS e.g.
  63564. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63565. */
  63566. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63567. updatable?: boolean;
  63568. });
  63569. /**
  63570. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63571. * If no points were added to the PCS, the returned mesh is just a single point.
  63572. * @returns a promise for the created mesh
  63573. */
  63574. buildMeshAsync(): Promise<Mesh>;
  63575. /**
  63576. * @hidden
  63577. */
  63578. private _buildMesh;
  63579. private _addParticle;
  63580. private _randomUnitVector;
  63581. private _getColorIndicesForCoord;
  63582. private _setPointsColorOrUV;
  63583. private _colorFromTexture;
  63584. private _calculateDensity;
  63585. /**
  63586. * Adds points to the PCS in random positions within a unit sphere
  63587. * @param nb (positive integer) the number of particles to be created from this model
  63588. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63589. * @returns the number of groups in the system
  63590. */
  63591. addPoints(nb: number, pointFunction?: any): number;
  63592. /**
  63593. * Adds points to the PCS from the surface of the model shape
  63594. * @param mesh is any Mesh object that will be used as a surface model for the points
  63595. * @param nb (positive integer) the number of particles to be created from this model
  63596. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63597. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63598. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63599. * @returns the number of groups in the system
  63600. */
  63601. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63602. /**
  63603. * Adds points to the PCS inside the model shape
  63604. * @param mesh is any Mesh object that will be used as a surface model for the points
  63605. * @param nb (positive integer) the number of particles to be created from this model
  63606. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63607. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63608. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63609. * @returns the number of groups in the system
  63610. */
  63611. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63612. /**
  63613. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63614. * This method calls `updateParticle()` for each particle of the SPS.
  63615. * For an animated SPS, it is usually called within the render loop.
  63616. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63617. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63618. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63619. * @returns the PCS.
  63620. */
  63621. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63622. /**
  63623. * Disposes the PCS.
  63624. */
  63625. dispose(): void;
  63626. /**
  63627. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63628. * doc :
  63629. * @returns the PCS.
  63630. */
  63631. refreshVisibleSize(): PointsCloudSystem;
  63632. /**
  63633. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63634. * @param size the size (float) of the visibility box
  63635. * note : this doesn't lock the PCS mesh bounding box.
  63636. * doc :
  63637. */
  63638. setVisibilityBox(size: number): void;
  63639. /**
  63640. * Gets whether the PCS is always visible or not
  63641. * doc :
  63642. */
  63643. get isAlwaysVisible(): boolean;
  63644. /**
  63645. * Sets the PCS as always visible or not
  63646. * doc :
  63647. */
  63648. set isAlwaysVisible(val: boolean);
  63649. /**
  63650. * Tells to `setParticles()` to compute the particle rotations or not
  63651. * Default value : false. The PCS is faster when it's set to false
  63652. * Note : particle rotations are only applied to parent particles
  63653. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63654. */
  63655. set computeParticleRotation(val: boolean);
  63656. /**
  63657. * Tells to `setParticles()` to compute the particle colors or not.
  63658. * Default value : true. The PCS is faster when it's set to false.
  63659. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63660. */
  63661. set computeParticleColor(val: boolean);
  63662. set computeParticleTexture(val: boolean);
  63663. /**
  63664. * Gets if `setParticles()` computes the particle colors or not.
  63665. * Default value : false. The PCS is faster when it's set to false.
  63666. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63667. */
  63668. get computeParticleColor(): boolean;
  63669. /**
  63670. * Gets if `setParticles()` computes the particle textures or not.
  63671. * Default value : false. The PCS is faster when it's set to false.
  63672. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63673. */
  63674. get computeParticleTexture(): boolean;
  63675. /**
  63676. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63677. */
  63678. set computeBoundingBox(val: boolean);
  63679. /**
  63680. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63681. */
  63682. get computeBoundingBox(): boolean;
  63683. /**
  63684. * This function does nothing. It may be overwritten to set all the particle first values.
  63685. * The PCS doesn't call this function, you may have to call it by your own.
  63686. * doc :
  63687. */
  63688. initParticles(): void;
  63689. /**
  63690. * This function does nothing. It may be overwritten to recycle a particle
  63691. * The PCS doesn't call this function, you can to call it
  63692. * doc :
  63693. * @param particle The particle to recycle
  63694. * @returns the recycled particle
  63695. */
  63696. recycleParticle(particle: CloudPoint): CloudPoint;
  63697. /**
  63698. * Updates a particle : this function should be overwritten by the user.
  63699. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63700. * doc :
  63701. * @example : just set a particle position or velocity and recycle conditions
  63702. * @param particle The particle to update
  63703. * @returns the updated particle
  63704. */
  63705. updateParticle(particle: CloudPoint): CloudPoint;
  63706. /**
  63707. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63708. * This does nothing and may be overwritten by the user.
  63709. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63710. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63711. * @param update the boolean update value actually passed to setParticles()
  63712. */
  63713. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63714. /**
  63715. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63716. * This will be passed three parameters.
  63717. * This does nothing and may be overwritten by the user.
  63718. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63719. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63720. * @param update the boolean update value actually passed to setParticles()
  63721. */
  63722. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63723. }
  63724. }
  63725. declare module BABYLON {
  63726. /**
  63727. * Represents one particle of a points cloud system.
  63728. */
  63729. export class CloudPoint {
  63730. /**
  63731. * particle global index
  63732. */
  63733. idx: number;
  63734. /**
  63735. * The color of the particle
  63736. */
  63737. color: Nullable<Color4>;
  63738. /**
  63739. * The world space position of the particle.
  63740. */
  63741. position: Vector3;
  63742. /**
  63743. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63744. */
  63745. rotation: Vector3;
  63746. /**
  63747. * The world space rotation quaternion of the particle.
  63748. */
  63749. rotationQuaternion: Nullable<Quaternion>;
  63750. /**
  63751. * The uv of the particle.
  63752. */
  63753. uv: Nullable<Vector2>;
  63754. /**
  63755. * The current speed of the particle.
  63756. */
  63757. velocity: Vector3;
  63758. /**
  63759. * The pivot point in the particle local space.
  63760. */
  63761. pivot: Vector3;
  63762. /**
  63763. * Must the particle be translated from its pivot point in its local space ?
  63764. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63765. * Default : false
  63766. */
  63767. translateFromPivot: boolean;
  63768. /**
  63769. * Index of this particle in the global "positions" array (Internal use)
  63770. * @hidden
  63771. */
  63772. _pos: number;
  63773. /**
  63774. * @hidden Index of this particle in the global "indices" array (Internal use)
  63775. */
  63776. _ind: number;
  63777. /**
  63778. * Group this particle belongs to
  63779. */
  63780. _group: PointsGroup;
  63781. /**
  63782. * Group id of this particle
  63783. */
  63784. groupId: number;
  63785. /**
  63786. * Index of the particle in its group id (Internal use)
  63787. */
  63788. idxInGroup: number;
  63789. /**
  63790. * @hidden Particle BoundingInfo object (Internal use)
  63791. */
  63792. _boundingInfo: BoundingInfo;
  63793. /**
  63794. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63795. */
  63796. _pcs: PointsCloudSystem;
  63797. /**
  63798. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63799. */
  63800. _stillInvisible: boolean;
  63801. /**
  63802. * @hidden Last computed particle rotation matrix
  63803. */
  63804. _rotationMatrix: number[];
  63805. /**
  63806. * Parent particle Id, if any.
  63807. * Default null.
  63808. */
  63809. parentId: Nullable<number>;
  63810. /**
  63811. * @hidden Internal global position in the PCS.
  63812. */
  63813. _globalPosition: Vector3;
  63814. /**
  63815. * Creates a Point Cloud object.
  63816. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63817. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63818. * @param group (PointsGroup) is the group the particle belongs to
  63819. * @param groupId (integer) is the group identifier in the PCS.
  63820. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63821. * @param pcs defines the PCS it is associated to
  63822. */
  63823. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63824. /**
  63825. * get point size
  63826. */
  63827. get size(): Vector3;
  63828. /**
  63829. * Set point size
  63830. */
  63831. set size(scale: Vector3);
  63832. /**
  63833. * Legacy support, changed quaternion to rotationQuaternion
  63834. */
  63835. get quaternion(): Nullable<Quaternion>;
  63836. /**
  63837. * Legacy support, changed quaternion to rotationQuaternion
  63838. */
  63839. set quaternion(q: Nullable<Quaternion>);
  63840. /**
  63841. * Returns a boolean. True if the particle intersects a mesh, else false
  63842. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63843. * @param target is the object (point or mesh) what the intersection is computed against
  63844. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63845. * @returns true if it intersects
  63846. */
  63847. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63848. /**
  63849. * get the rotation matrix of the particle
  63850. * @hidden
  63851. */
  63852. getRotationMatrix(m: Matrix): void;
  63853. }
  63854. /**
  63855. * Represents a group of points in a points cloud system
  63856. * * PCS internal tool, don't use it manually.
  63857. */
  63858. export class PointsGroup {
  63859. /**
  63860. * The group id
  63861. * @hidden
  63862. */
  63863. groupID: number;
  63864. /**
  63865. * image data for group (internal use)
  63866. * @hidden
  63867. */
  63868. _groupImageData: Nullable<ArrayBufferView>;
  63869. /**
  63870. * Image Width (internal use)
  63871. * @hidden
  63872. */
  63873. _groupImgWidth: number;
  63874. /**
  63875. * Image Height (internal use)
  63876. * @hidden
  63877. */
  63878. _groupImgHeight: number;
  63879. /**
  63880. * Custom position function (internal use)
  63881. * @hidden
  63882. */
  63883. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63884. /**
  63885. * density per facet for surface points
  63886. * @hidden
  63887. */
  63888. _groupDensity: number[];
  63889. /**
  63890. * Only when points are colored by texture carries pointer to texture list array
  63891. * @hidden
  63892. */
  63893. _textureNb: number;
  63894. /**
  63895. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63896. * PCS internal tool, don't use it manually.
  63897. * @hidden
  63898. */
  63899. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63900. }
  63901. }
  63902. declare module BABYLON {
  63903. interface Scene {
  63904. /** @hidden (Backing field) */
  63905. _physicsEngine: Nullable<IPhysicsEngine>;
  63906. /** @hidden */
  63907. _physicsTimeAccumulator: number;
  63908. /**
  63909. * Gets the current physics engine
  63910. * @returns a IPhysicsEngine or null if none attached
  63911. */
  63912. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63913. /**
  63914. * Enables physics to the current scene
  63915. * @param gravity defines the scene's gravity for the physics engine
  63916. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63917. * @return a boolean indicating if the physics engine was initialized
  63918. */
  63919. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63920. /**
  63921. * Disables and disposes the physics engine associated with the scene
  63922. */
  63923. disablePhysicsEngine(): void;
  63924. /**
  63925. * Gets a boolean indicating if there is an active physics engine
  63926. * @returns a boolean indicating if there is an active physics engine
  63927. */
  63928. isPhysicsEnabled(): boolean;
  63929. /**
  63930. * Deletes a physics compound impostor
  63931. * @param compound defines the compound to delete
  63932. */
  63933. deleteCompoundImpostor(compound: any): void;
  63934. /**
  63935. * An event triggered when physic simulation is about to be run
  63936. */
  63937. onBeforePhysicsObservable: Observable<Scene>;
  63938. /**
  63939. * An event triggered when physic simulation has been done
  63940. */
  63941. onAfterPhysicsObservable: Observable<Scene>;
  63942. }
  63943. interface AbstractMesh {
  63944. /** @hidden */
  63945. _physicsImpostor: Nullable<PhysicsImpostor>;
  63946. /**
  63947. * Gets or sets impostor used for physic simulation
  63948. * @see http://doc.babylonjs.com/features/physics_engine
  63949. */
  63950. physicsImpostor: Nullable<PhysicsImpostor>;
  63951. /**
  63952. * Gets the current physics impostor
  63953. * @see http://doc.babylonjs.com/features/physics_engine
  63954. * @returns a physics impostor or null
  63955. */
  63956. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63957. /** Apply a physic impulse to the mesh
  63958. * @param force defines the force to apply
  63959. * @param contactPoint defines where to apply the force
  63960. * @returns the current mesh
  63961. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63962. */
  63963. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63964. /**
  63965. * Creates a physic joint between two meshes
  63966. * @param otherMesh defines the other mesh to use
  63967. * @param pivot1 defines the pivot to use on this mesh
  63968. * @param pivot2 defines the pivot to use on the other mesh
  63969. * @param options defines additional options (can be plugin dependent)
  63970. * @returns the current mesh
  63971. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63972. */
  63973. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63974. /** @hidden */
  63975. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63976. }
  63977. /**
  63978. * Defines the physics engine scene component responsible to manage a physics engine
  63979. */
  63980. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63981. /**
  63982. * The component name helpful to identify the component in the list of scene components.
  63983. */
  63984. readonly name: string;
  63985. /**
  63986. * The scene the component belongs to.
  63987. */
  63988. scene: Scene;
  63989. /**
  63990. * Creates a new instance of the component for the given scene
  63991. * @param scene Defines the scene to register the component in
  63992. */
  63993. constructor(scene: Scene);
  63994. /**
  63995. * Registers the component in a given scene
  63996. */
  63997. register(): void;
  63998. /**
  63999. * Rebuilds the elements related to this component in case of
  64000. * context lost for instance.
  64001. */
  64002. rebuild(): void;
  64003. /**
  64004. * Disposes the component and the associated ressources
  64005. */
  64006. dispose(): void;
  64007. }
  64008. }
  64009. declare module BABYLON {
  64010. /**
  64011. * A helper for physics simulations
  64012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64013. */
  64014. export class PhysicsHelper {
  64015. private _scene;
  64016. private _physicsEngine;
  64017. /**
  64018. * Initializes the Physics helper
  64019. * @param scene Babylon.js scene
  64020. */
  64021. constructor(scene: Scene);
  64022. /**
  64023. * Applies a radial explosion impulse
  64024. * @param origin the origin of the explosion
  64025. * @param radiusOrEventOptions the radius or the options of radial explosion
  64026. * @param strength the explosion strength
  64027. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64028. * @returns A physics radial explosion event, or null
  64029. */
  64030. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64031. /**
  64032. * Applies a radial explosion force
  64033. * @param origin the origin of the explosion
  64034. * @param radiusOrEventOptions the radius or the options of radial explosion
  64035. * @param strength the explosion strength
  64036. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64037. * @returns A physics radial explosion event, or null
  64038. */
  64039. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64040. /**
  64041. * Creates a gravitational field
  64042. * @param origin the origin of the explosion
  64043. * @param radiusOrEventOptions the radius or the options of radial explosion
  64044. * @param strength the explosion strength
  64045. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64046. * @returns A physics gravitational field event, or null
  64047. */
  64048. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64049. /**
  64050. * Creates a physics updraft event
  64051. * @param origin the origin of the updraft
  64052. * @param radiusOrEventOptions the radius or the options of the updraft
  64053. * @param strength the strength of the updraft
  64054. * @param height the height of the updraft
  64055. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64056. * @returns A physics updraft event, or null
  64057. */
  64058. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64059. /**
  64060. * Creates a physics vortex event
  64061. * @param origin the of the vortex
  64062. * @param radiusOrEventOptions the radius or the options of the vortex
  64063. * @param strength the strength of the vortex
  64064. * @param height the height of the vortex
  64065. * @returns a Physics vortex event, or null
  64066. * A physics vortex event or null
  64067. */
  64068. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64069. }
  64070. /**
  64071. * Represents a physics radial explosion event
  64072. */
  64073. class PhysicsRadialExplosionEvent {
  64074. private _scene;
  64075. private _options;
  64076. private _sphere;
  64077. private _dataFetched;
  64078. /**
  64079. * Initializes a radial explosioin event
  64080. * @param _scene BabylonJS scene
  64081. * @param _options The options for the vortex event
  64082. */
  64083. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64084. /**
  64085. * Returns the data related to the radial explosion event (sphere).
  64086. * @returns The radial explosion event data
  64087. */
  64088. getData(): PhysicsRadialExplosionEventData;
  64089. /**
  64090. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64091. * @param impostor A physics imposter
  64092. * @param origin the origin of the explosion
  64093. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64094. */
  64095. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64096. /**
  64097. * Triggers affecterd impostors callbacks
  64098. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64099. */
  64100. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64101. /**
  64102. * Disposes the sphere.
  64103. * @param force Specifies if the sphere should be disposed by force
  64104. */
  64105. dispose(force?: boolean): void;
  64106. /*** Helpers ***/
  64107. private _prepareSphere;
  64108. private _intersectsWithSphere;
  64109. }
  64110. /**
  64111. * Represents a gravitational field event
  64112. */
  64113. class PhysicsGravitationalFieldEvent {
  64114. private _physicsHelper;
  64115. private _scene;
  64116. private _origin;
  64117. private _options;
  64118. private _tickCallback;
  64119. private _sphere;
  64120. private _dataFetched;
  64121. /**
  64122. * Initializes the physics gravitational field event
  64123. * @param _physicsHelper A physics helper
  64124. * @param _scene BabylonJS scene
  64125. * @param _origin The origin position of the gravitational field event
  64126. * @param _options The options for the vortex event
  64127. */
  64128. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64129. /**
  64130. * Returns the data related to the gravitational field event (sphere).
  64131. * @returns A gravitational field event
  64132. */
  64133. getData(): PhysicsGravitationalFieldEventData;
  64134. /**
  64135. * Enables the gravitational field.
  64136. */
  64137. enable(): void;
  64138. /**
  64139. * Disables the gravitational field.
  64140. */
  64141. disable(): void;
  64142. /**
  64143. * Disposes the sphere.
  64144. * @param force The force to dispose from the gravitational field event
  64145. */
  64146. dispose(force?: boolean): void;
  64147. private _tick;
  64148. }
  64149. /**
  64150. * Represents a physics updraft event
  64151. */
  64152. class PhysicsUpdraftEvent {
  64153. private _scene;
  64154. private _origin;
  64155. private _options;
  64156. private _physicsEngine;
  64157. private _originTop;
  64158. private _originDirection;
  64159. private _tickCallback;
  64160. private _cylinder;
  64161. private _cylinderPosition;
  64162. private _dataFetched;
  64163. /**
  64164. * Initializes the physics updraft event
  64165. * @param _scene BabylonJS scene
  64166. * @param _origin The origin position of the updraft
  64167. * @param _options The options for the updraft event
  64168. */
  64169. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64170. /**
  64171. * Returns the data related to the updraft event (cylinder).
  64172. * @returns A physics updraft event
  64173. */
  64174. getData(): PhysicsUpdraftEventData;
  64175. /**
  64176. * Enables the updraft.
  64177. */
  64178. enable(): void;
  64179. /**
  64180. * Disables the updraft.
  64181. */
  64182. disable(): void;
  64183. /**
  64184. * Disposes the cylinder.
  64185. * @param force Specifies if the updraft should be disposed by force
  64186. */
  64187. dispose(force?: boolean): void;
  64188. private getImpostorHitData;
  64189. private _tick;
  64190. /*** Helpers ***/
  64191. private _prepareCylinder;
  64192. private _intersectsWithCylinder;
  64193. }
  64194. /**
  64195. * Represents a physics vortex event
  64196. */
  64197. class PhysicsVortexEvent {
  64198. private _scene;
  64199. private _origin;
  64200. private _options;
  64201. private _physicsEngine;
  64202. private _originTop;
  64203. private _tickCallback;
  64204. private _cylinder;
  64205. private _cylinderPosition;
  64206. private _dataFetched;
  64207. /**
  64208. * Initializes the physics vortex event
  64209. * @param _scene The BabylonJS scene
  64210. * @param _origin The origin position of the vortex
  64211. * @param _options The options for the vortex event
  64212. */
  64213. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64214. /**
  64215. * Returns the data related to the vortex event (cylinder).
  64216. * @returns The physics vortex event data
  64217. */
  64218. getData(): PhysicsVortexEventData;
  64219. /**
  64220. * Enables the vortex.
  64221. */
  64222. enable(): void;
  64223. /**
  64224. * Disables the cortex.
  64225. */
  64226. disable(): void;
  64227. /**
  64228. * Disposes the sphere.
  64229. * @param force
  64230. */
  64231. dispose(force?: boolean): void;
  64232. private getImpostorHitData;
  64233. private _tick;
  64234. /*** Helpers ***/
  64235. private _prepareCylinder;
  64236. private _intersectsWithCylinder;
  64237. }
  64238. /**
  64239. * Options fot the radial explosion event
  64240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64241. */
  64242. export class PhysicsRadialExplosionEventOptions {
  64243. /**
  64244. * The radius of the sphere for the radial explosion.
  64245. */
  64246. radius: number;
  64247. /**
  64248. * The strenth of the explosion.
  64249. */
  64250. strength: number;
  64251. /**
  64252. * The strenght of the force in correspondence to the distance of the affected object
  64253. */
  64254. falloff: PhysicsRadialImpulseFalloff;
  64255. /**
  64256. * Sphere options for the radial explosion.
  64257. */
  64258. sphere: {
  64259. segments: number;
  64260. diameter: number;
  64261. };
  64262. /**
  64263. * Sphere options for the radial explosion.
  64264. */
  64265. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64266. }
  64267. /**
  64268. * Options fot the updraft event
  64269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64270. */
  64271. export class PhysicsUpdraftEventOptions {
  64272. /**
  64273. * The radius of the cylinder for the vortex
  64274. */
  64275. radius: number;
  64276. /**
  64277. * The strenth of the updraft.
  64278. */
  64279. strength: number;
  64280. /**
  64281. * The height of the cylinder for the updraft.
  64282. */
  64283. height: number;
  64284. /**
  64285. * The mode for the the updraft.
  64286. */
  64287. updraftMode: PhysicsUpdraftMode;
  64288. }
  64289. /**
  64290. * Options fot the vortex event
  64291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64292. */
  64293. export class PhysicsVortexEventOptions {
  64294. /**
  64295. * The radius of the cylinder for the vortex
  64296. */
  64297. radius: number;
  64298. /**
  64299. * The strenth of the vortex.
  64300. */
  64301. strength: number;
  64302. /**
  64303. * The height of the cylinder for the vortex.
  64304. */
  64305. height: number;
  64306. /**
  64307. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64308. */
  64309. centripetalForceThreshold: number;
  64310. /**
  64311. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64312. */
  64313. centripetalForceMultiplier: number;
  64314. /**
  64315. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64316. */
  64317. centrifugalForceMultiplier: number;
  64318. /**
  64319. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64320. */
  64321. updraftForceMultiplier: number;
  64322. }
  64323. /**
  64324. * The strenght of the force in correspondence to the distance of the affected object
  64325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64326. */
  64327. export enum PhysicsRadialImpulseFalloff {
  64328. /** Defines that impulse is constant in strength across it's whole radius */
  64329. Constant = 0,
  64330. /** Defines that impulse gets weaker if it's further from the origin */
  64331. Linear = 1
  64332. }
  64333. /**
  64334. * The strength of the force in correspondence to the distance of the affected object
  64335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64336. */
  64337. export enum PhysicsUpdraftMode {
  64338. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64339. Center = 0,
  64340. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64341. Perpendicular = 1
  64342. }
  64343. /**
  64344. * Interface for a physics hit data
  64345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64346. */
  64347. export interface PhysicsHitData {
  64348. /**
  64349. * The force applied at the contact point
  64350. */
  64351. force: Vector3;
  64352. /**
  64353. * The contact point
  64354. */
  64355. contactPoint: Vector3;
  64356. /**
  64357. * The distance from the origin to the contact point
  64358. */
  64359. distanceFromOrigin: number;
  64360. }
  64361. /**
  64362. * Interface for radial explosion event data
  64363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64364. */
  64365. export interface PhysicsRadialExplosionEventData {
  64366. /**
  64367. * A sphere used for the radial explosion event
  64368. */
  64369. sphere: Mesh;
  64370. }
  64371. /**
  64372. * Interface for gravitational field event data
  64373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64374. */
  64375. export interface PhysicsGravitationalFieldEventData {
  64376. /**
  64377. * A sphere mesh used for the gravitational field event
  64378. */
  64379. sphere: Mesh;
  64380. }
  64381. /**
  64382. * Interface for updraft event data
  64383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64384. */
  64385. export interface PhysicsUpdraftEventData {
  64386. /**
  64387. * A cylinder used for the updraft event
  64388. */
  64389. cylinder: Mesh;
  64390. }
  64391. /**
  64392. * Interface for vortex event data
  64393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64394. */
  64395. export interface PhysicsVortexEventData {
  64396. /**
  64397. * A cylinder used for the vortex event
  64398. */
  64399. cylinder: Mesh;
  64400. }
  64401. /**
  64402. * Interface for an affected physics impostor
  64403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64404. */
  64405. export interface PhysicsAffectedImpostorWithData {
  64406. /**
  64407. * The impostor affected by the effect
  64408. */
  64409. impostor: PhysicsImpostor;
  64410. /**
  64411. * The data about the hit/horce from the explosion
  64412. */
  64413. hitData: PhysicsHitData;
  64414. }
  64415. }
  64416. declare module BABYLON {
  64417. /** @hidden */
  64418. export var blackAndWhitePixelShader: {
  64419. name: string;
  64420. shader: string;
  64421. };
  64422. }
  64423. declare module BABYLON {
  64424. /**
  64425. * Post process used to render in black and white
  64426. */
  64427. export class BlackAndWhitePostProcess extends PostProcess {
  64428. /**
  64429. * Linear about to convert he result to black and white (default: 1)
  64430. */
  64431. degree: number;
  64432. /**
  64433. * Creates a black and white post process
  64434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64435. * @param name The name of the effect.
  64436. * @param options The required width/height ratio to downsize to before computing the render pass.
  64437. * @param camera The camera to apply the render pass to.
  64438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64439. * @param engine The engine which the post process will be applied. (default: current engine)
  64440. * @param reusable If the post process can be reused on the same frame. (default: false)
  64441. */
  64442. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /**
  64447. * This represents a set of one or more post processes in Babylon.
  64448. * A post process can be used to apply a shader to a texture after it is rendered.
  64449. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64450. */
  64451. export class PostProcessRenderEffect {
  64452. private _postProcesses;
  64453. private _getPostProcesses;
  64454. private _singleInstance;
  64455. private _cameras;
  64456. private _indicesForCamera;
  64457. /**
  64458. * Name of the effect
  64459. * @hidden
  64460. */
  64461. _name: string;
  64462. /**
  64463. * Instantiates a post process render effect.
  64464. * A post process can be used to apply a shader to a texture after it is rendered.
  64465. * @param engine The engine the effect is tied to
  64466. * @param name The name of the effect
  64467. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64468. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64469. */
  64470. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64471. /**
  64472. * Checks if all the post processes in the effect are supported.
  64473. */
  64474. get isSupported(): boolean;
  64475. /**
  64476. * Updates the current state of the effect
  64477. * @hidden
  64478. */
  64479. _update(): void;
  64480. /**
  64481. * Attaches the effect on cameras
  64482. * @param cameras The camera to attach to.
  64483. * @hidden
  64484. */
  64485. _attachCameras(cameras: Camera): void;
  64486. /**
  64487. * Attaches the effect on cameras
  64488. * @param cameras The camera to attach to.
  64489. * @hidden
  64490. */
  64491. _attachCameras(cameras: Camera[]): void;
  64492. /**
  64493. * Detaches the effect on cameras
  64494. * @param cameras The camera to detatch from.
  64495. * @hidden
  64496. */
  64497. _detachCameras(cameras: Camera): void;
  64498. /**
  64499. * Detatches the effect on cameras
  64500. * @param cameras The camera to detatch from.
  64501. * @hidden
  64502. */
  64503. _detachCameras(cameras: Camera[]): void;
  64504. /**
  64505. * Enables the effect on given cameras
  64506. * @param cameras The camera to enable.
  64507. * @hidden
  64508. */
  64509. _enable(cameras: Camera): void;
  64510. /**
  64511. * Enables the effect on given cameras
  64512. * @param cameras The camera to enable.
  64513. * @hidden
  64514. */
  64515. _enable(cameras: Nullable<Camera[]>): void;
  64516. /**
  64517. * Disables the effect on the given cameras
  64518. * @param cameras The camera to disable.
  64519. * @hidden
  64520. */
  64521. _disable(cameras: Camera): void;
  64522. /**
  64523. * Disables the effect on the given cameras
  64524. * @param cameras The camera to disable.
  64525. * @hidden
  64526. */
  64527. _disable(cameras: Nullable<Camera[]>): void;
  64528. /**
  64529. * Gets a list of the post processes contained in the effect.
  64530. * @param camera The camera to get the post processes on.
  64531. * @returns The list of the post processes in the effect.
  64532. */
  64533. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64534. }
  64535. }
  64536. declare module BABYLON {
  64537. /** @hidden */
  64538. export var extractHighlightsPixelShader: {
  64539. name: string;
  64540. shader: string;
  64541. };
  64542. }
  64543. declare module BABYLON {
  64544. /**
  64545. * 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.
  64546. */
  64547. export class ExtractHighlightsPostProcess extends PostProcess {
  64548. /**
  64549. * The luminance threshold, pixels below this value will be set to black.
  64550. */
  64551. threshold: number;
  64552. /** @hidden */
  64553. _exposure: number;
  64554. /**
  64555. * Post process which has the input texture to be used when performing highlight extraction
  64556. * @hidden
  64557. */
  64558. _inputPostProcess: Nullable<PostProcess>;
  64559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64560. }
  64561. }
  64562. declare module BABYLON {
  64563. /** @hidden */
  64564. export var bloomMergePixelShader: {
  64565. name: string;
  64566. shader: string;
  64567. };
  64568. }
  64569. declare module BABYLON {
  64570. /**
  64571. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64572. */
  64573. export class BloomMergePostProcess extends PostProcess {
  64574. /** Weight of the bloom to be added to the original input. */
  64575. weight: number;
  64576. /**
  64577. * Creates a new instance of @see BloomMergePostProcess
  64578. * @param name The name of the effect.
  64579. * @param originalFromInput Post process which's input will be used for the merge.
  64580. * @param blurred Blurred highlights post process which's output will be used.
  64581. * @param weight Weight of the bloom to be added to the original input.
  64582. * @param options The required width/height ratio to downsize to before computing the render pass.
  64583. * @param camera The camera to apply the render pass to.
  64584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64585. * @param engine The engine which the post process will be applied. (default: current engine)
  64586. * @param reusable If the post process can be reused on the same frame. (default: false)
  64587. * @param textureType Type of textures used when performing the post process. (default: 0)
  64588. * @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)
  64589. */
  64590. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64591. /** Weight of the bloom to be added to the original input. */
  64592. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64593. }
  64594. }
  64595. declare module BABYLON {
  64596. /**
  64597. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64598. */
  64599. export class BloomEffect extends PostProcessRenderEffect {
  64600. private bloomScale;
  64601. /**
  64602. * @hidden Internal
  64603. */
  64604. _effects: Array<PostProcess>;
  64605. /**
  64606. * @hidden Internal
  64607. */
  64608. _downscale: ExtractHighlightsPostProcess;
  64609. private _blurX;
  64610. private _blurY;
  64611. private _merge;
  64612. /**
  64613. * The luminance threshold to find bright areas of the image to bloom.
  64614. */
  64615. get threshold(): number;
  64616. set threshold(value: number);
  64617. /**
  64618. * The strength of the bloom.
  64619. */
  64620. get weight(): number;
  64621. set weight(value: number);
  64622. /**
  64623. * Specifies the size of the bloom blur kernel, relative to the final output size
  64624. */
  64625. get kernel(): number;
  64626. set kernel(value: number);
  64627. /**
  64628. * Creates a new instance of @see BloomEffect
  64629. * @param scene The scene the effect belongs to.
  64630. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64631. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64632. * @param bloomWeight The the strength of bloom.
  64633. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64634. * @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)
  64635. */
  64636. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64637. /**
  64638. * Disposes each of the internal effects for a given camera.
  64639. * @param camera The camera to dispose the effect on.
  64640. */
  64641. disposeEffects(camera: Camera): void;
  64642. /**
  64643. * @hidden Internal
  64644. */
  64645. _updateEffects(): void;
  64646. /**
  64647. * Internal
  64648. * @returns if all the contained post processes are ready.
  64649. * @hidden
  64650. */
  64651. _isReady(): boolean;
  64652. }
  64653. }
  64654. declare module BABYLON {
  64655. /** @hidden */
  64656. export var chromaticAberrationPixelShader: {
  64657. name: string;
  64658. shader: string;
  64659. };
  64660. }
  64661. declare module BABYLON {
  64662. /**
  64663. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64664. */
  64665. export class ChromaticAberrationPostProcess extends PostProcess {
  64666. /**
  64667. * The amount of seperation of rgb channels (default: 30)
  64668. */
  64669. aberrationAmount: number;
  64670. /**
  64671. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64672. */
  64673. radialIntensity: number;
  64674. /**
  64675. * 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))
  64676. */
  64677. direction: Vector2;
  64678. /**
  64679. * 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))
  64680. */
  64681. centerPosition: Vector2;
  64682. /**
  64683. * Creates a new instance ChromaticAberrationPostProcess
  64684. * @param name The name of the effect.
  64685. * @param screenWidth The width of the screen to apply the effect on.
  64686. * @param screenHeight The height of the screen to apply the effect on.
  64687. * @param options The required width/height ratio to downsize to before computing the render pass.
  64688. * @param camera The camera to apply the render pass to.
  64689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64690. * @param engine The engine which the post process will be applied. (default: current engine)
  64691. * @param reusable If the post process can be reused on the same frame. (default: false)
  64692. * @param textureType Type of textures used when performing the post process. (default: 0)
  64693. * @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)
  64694. */
  64695. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64696. }
  64697. }
  64698. declare module BABYLON {
  64699. /** @hidden */
  64700. export var circleOfConfusionPixelShader: {
  64701. name: string;
  64702. shader: string;
  64703. };
  64704. }
  64705. declare module BABYLON {
  64706. /**
  64707. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64708. */
  64709. export class CircleOfConfusionPostProcess extends PostProcess {
  64710. /**
  64711. * 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.
  64712. */
  64713. lensSize: number;
  64714. /**
  64715. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64716. */
  64717. fStop: number;
  64718. /**
  64719. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64720. */
  64721. focusDistance: number;
  64722. /**
  64723. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64724. */
  64725. focalLength: number;
  64726. private _depthTexture;
  64727. /**
  64728. * Creates a new instance CircleOfConfusionPostProcess
  64729. * @param name The name of the effect.
  64730. * @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.
  64731. * @param options The required width/height ratio to downsize to before computing the render pass.
  64732. * @param camera The camera to apply the render pass to.
  64733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64734. * @param engine The engine which the post process will be applied. (default: current engine)
  64735. * @param reusable If the post process can be reused on the same frame. (default: false)
  64736. * @param textureType Type of textures used when performing the post process. (default: 0)
  64737. * @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)
  64738. */
  64739. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64740. /**
  64741. * 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.
  64742. */
  64743. set depthTexture(value: RenderTargetTexture);
  64744. }
  64745. }
  64746. declare module BABYLON {
  64747. /** @hidden */
  64748. export var colorCorrectionPixelShader: {
  64749. name: string;
  64750. shader: string;
  64751. };
  64752. }
  64753. declare module BABYLON {
  64754. /**
  64755. *
  64756. * This post-process allows the modification of rendered colors by using
  64757. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64758. *
  64759. * The object needs to be provided an url to a texture containing the color
  64760. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64761. * Use an image editing software to tweak the LUT to match your needs.
  64762. *
  64763. * For an example of a color LUT, see here:
  64764. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64765. * For explanations on color grading, see here:
  64766. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64767. *
  64768. */
  64769. export class ColorCorrectionPostProcess extends PostProcess {
  64770. private _colorTableTexture;
  64771. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64772. }
  64773. }
  64774. declare module BABYLON {
  64775. /** @hidden */
  64776. export var convolutionPixelShader: {
  64777. name: string;
  64778. shader: string;
  64779. };
  64780. }
  64781. declare module BABYLON {
  64782. /**
  64783. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64784. * input texture to perform effects such as edge detection or sharpening
  64785. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64786. */
  64787. export class ConvolutionPostProcess extends PostProcess {
  64788. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64789. kernel: number[];
  64790. /**
  64791. * Creates a new instance ConvolutionPostProcess
  64792. * @param name The name of the effect.
  64793. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64794. * @param options The required width/height ratio to downsize to before computing the render pass.
  64795. * @param camera The camera to apply the render pass to.
  64796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64797. * @param engine The engine which the post process will be applied. (default: current engine)
  64798. * @param reusable If the post process can be reused on the same frame. (default: false)
  64799. * @param textureType Type of textures used when performing the post process. (default: 0)
  64800. */
  64801. constructor(name: string,
  64802. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64803. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64804. /**
  64805. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64806. */
  64807. static EdgeDetect0Kernel: number[];
  64808. /**
  64809. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64810. */
  64811. static EdgeDetect1Kernel: number[];
  64812. /**
  64813. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64814. */
  64815. static EdgeDetect2Kernel: number[];
  64816. /**
  64817. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64818. */
  64819. static SharpenKernel: number[];
  64820. /**
  64821. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64822. */
  64823. static EmbossKernel: number[];
  64824. /**
  64825. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64826. */
  64827. static GaussianKernel: number[];
  64828. }
  64829. }
  64830. declare module BABYLON {
  64831. /**
  64832. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64833. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64834. * based on samples that have a large difference in distance than the center pixel.
  64835. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64836. */
  64837. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64838. direction: Vector2;
  64839. /**
  64840. * Creates a new instance CircleOfConfusionPostProcess
  64841. * @param name The name of the effect.
  64842. * @param scene The scene the effect belongs to.
  64843. * @param direction The direction the blur should be applied.
  64844. * @param kernel The size of the kernel used to blur.
  64845. * @param options The required width/height ratio to downsize to before computing the render pass.
  64846. * @param camera The camera to apply the render pass to.
  64847. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64848. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64850. * @param engine The engine which the post process will be applied. (default: current engine)
  64851. * @param reusable If the post process can be reused on the same frame. (default: false)
  64852. * @param textureType Type of textures used when performing the post process. (default: 0)
  64853. * @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)
  64854. */
  64855. 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);
  64856. }
  64857. }
  64858. declare module BABYLON {
  64859. /** @hidden */
  64860. export var depthOfFieldMergePixelShader: {
  64861. name: string;
  64862. shader: string;
  64863. };
  64864. }
  64865. declare module BABYLON {
  64866. /**
  64867. * Options to be set when merging outputs from the default pipeline.
  64868. */
  64869. export class DepthOfFieldMergePostProcessOptions {
  64870. /**
  64871. * The original image to merge on top of
  64872. */
  64873. originalFromInput: PostProcess;
  64874. /**
  64875. * Parameters to perform the merge of the depth of field effect
  64876. */
  64877. depthOfField?: {
  64878. circleOfConfusion: PostProcess;
  64879. blurSteps: Array<PostProcess>;
  64880. };
  64881. /**
  64882. * Parameters to perform the merge of bloom effect
  64883. */
  64884. bloom?: {
  64885. blurred: PostProcess;
  64886. weight: number;
  64887. };
  64888. }
  64889. /**
  64890. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64891. */
  64892. export class DepthOfFieldMergePostProcess extends PostProcess {
  64893. private blurSteps;
  64894. /**
  64895. * Creates a new instance of DepthOfFieldMergePostProcess
  64896. * @param name The name of the effect.
  64897. * @param originalFromInput Post process which's input will be used for the merge.
  64898. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64899. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64900. * @param options The required width/height ratio to downsize to before computing the render pass.
  64901. * @param camera The camera to apply the render pass to.
  64902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64903. * @param engine The engine which the post process will be applied. (default: current engine)
  64904. * @param reusable If the post process can be reused on the same frame. (default: false)
  64905. * @param textureType Type of textures used when performing the post process. (default: 0)
  64906. * @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)
  64907. */
  64908. 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);
  64909. /**
  64910. * Updates the effect with the current post process compile time values and recompiles the shader.
  64911. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64912. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64913. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64914. * @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
  64915. * @param onCompiled Called when the shader has been compiled.
  64916. * @param onError Called if there is an error when compiling a shader.
  64917. */
  64918. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64919. }
  64920. }
  64921. declare module BABYLON {
  64922. /**
  64923. * Specifies the level of max blur that should be applied when using the depth of field effect
  64924. */
  64925. export enum DepthOfFieldEffectBlurLevel {
  64926. /**
  64927. * Subtle blur
  64928. */
  64929. Low = 0,
  64930. /**
  64931. * Medium blur
  64932. */
  64933. Medium = 1,
  64934. /**
  64935. * Large blur
  64936. */
  64937. High = 2
  64938. }
  64939. /**
  64940. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64941. */
  64942. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64943. private _circleOfConfusion;
  64944. /**
  64945. * @hidden Internal, blurs from high to low
  64946. */
  64947. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64948. private _depthOfFieldBlurY;
  64949. private _dofMerge;
  64950. /**
  64951. * @hidden Internal post processes in depth of field effect
  64952. */
  64953. _effects: Array<PostProcess>;
  64954. /**
  64955. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64956. */
  64957. set focalLength(value: number);
  64958. get focalLength(): number;
  64959. /**
  64960. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64961. */
  64962. set fStop(value: number);
  64963. get fStop(): number;
  64964. /**
  64965. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64966. */
  64967. set focusDistance(value: number);
  64968. get focusDistance(): number;
  64969. /**
  64970. * 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.
  64971. */
  64972. set lensSize(value: number);
  64973. get lensSize(): number;
  64974. /**
  64975. * Creates a new instance DepthOfFieldEffect
  64976. * @param scene The scene the effect belongs to.
  64977. * @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.
  64978. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64979. * @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)
  64980. */
  64981. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64982. /**
  64983. * Get the current class name of the current effet
  64984. * @returns "DepthOfFieldEffect"
  64985. */
  64986. getClassName(): string;
  64987. /**
  64988. * 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.
  64989. */
  64990. set depthTexture(value: RenderTargetTexture);
  64991. /**
  64992. * Disposes each of the internal effects for a given camera.
  64993. * @param camera The camera to dispose the effect on.
  64994. */
  64995. disposeEffects(camera: Camera): void;
  64996. /**
  64997. * @hidden Internal
  64998. */
  64999. _updateEffects(): void;
  65000. /**
  65001. * Internal
  65002. * @returns if all the contained post processes are ready.
  65003. * @hidden
  65004. */
  65005. _isReady(): boolean;
  65006. }
  65007. }
  65008. declare module BABYLON {
  65009. /** @hidden */
  65010. export var displayPassPixelShader: {
  65011. name: string;
  65012. shader: string;
  65013. };
  65014. }
  65015. declare module BABYLON {
  65016. /**
  65017. * DisplayPassPostProcess which produces an output the same as it's input
  65018. */
  65019. export class DisplayPassPostProcess extends PostProcess {
  65020. /**
  65021. * Creates the DisplayPassPostProcess
  65022. * @param name The name of the effect.
  65023. * @param options The required width/height ratio to downsize to before computing the render pass.
  65024. * @param camera The camera to apply the render pass to.
  65025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65026. * @param engine The engine which the post process will be applied. (default: current engine)
  65027. * @param reusable If the post process can be reused on the same frame. (default: false)
  65028. */
  65029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /** @hidden */
  65034. export var filterPixelShader: {
  65035. name: string;
  65036. shader: string;
  65037. };
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * Applies a kernel filter to the image
  65042. */
  65043. export class FilterPostProcess extends PostProcess {
  65044. /** The matrix to be applied to the image */
  65045. kernelMatrix: Matrix;
  65046. /**
  65047. *
  65048. * @param name The name of the effect.
  65049. * @param kernelMatrix The matrix to be applied to the image
  65050. * @param options The required width/height ratio to downsize to before computing the render pass.
  65051. * @param camera The camera to apply the render pass to.
  65052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65053. * @param engine The engine which the post process will be applied. (default: current engine)
  65054. * @param reusable If the post process can be reused on the same frame. (default: false)
  65055. */
  65056. constructor(name: string,
  65057. /** The matrix to be applied to the image */
  65058. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65059. }
  65060. }
  65061. declare module BABYLON {
  65062. /** @hidden */
  65063. export var fxaaPixelShader: {
  65064. name: string;
  65065. shader: string;
  65066. };
  65067. }
  65068. declare module BABYLON {
  65069. /** @hidden */
  65070. export var fxaaVertexShader: {
  65071. name: string;
  65072. shader: string;
  65073. };
  65074. }
  65075. declare module BABYLON {
  65076. /**
  65077. * Fxaa post process
  65078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65079. */
  65080. export class FxaaPostProcess extends PostProcess {
  65081. /** @hidden */
  65082. texelWidth: number;
  65083. /** @hidden */
  65084. texelHeight: number;
  65085. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65086. private _getDefines;
  65087. }
  65088. }
  65089. declare module BABYLON {
  65090. /** @hidden */
  65091. export var grainPixelShader: {
  65092. name: string;
  65093. shader: string;
  65094. };
  65095. }
  65096. declare module BABYLON {
  65097. /**
  65098. * The GrainPostProcess adds noise to the image at mid luminance levels
  65099. */
  65100. export class GrainPostProcess extends PostProcess {
  65101. /**
  65102. * The intensity of the grain added (default: 30)
  65103. */
  65104. intensity: number;
  65105. /**
  65106. * If the grain should be randomized on every frame
  65107. */
  65108. animated: boolean;
  65109. /**
  65110. * Creates a new instance of @see GrainPostProcess
  65111. * @param name The name of the effect.
  65112. * @param options The required width/height ratio to downsize to before computing the render pass.
  65113. * @param camera The camera to apply the render pass to.
  65114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65115. * @param engine The engine which the post process will be applied. (default: current engine)
  65116. * @param reusable If the post process can be reused on the same frame. (default: false)
  65117. * @param textureType Type of textures used when performing the post process. (default: 0)
  65118. * @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)
  65119. */
  65120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65121. }
  65122. }
  65123. declare module BABYLON {
  65124. /** @hidden */
  65125. export var highlightsPixelShader: {
  65126. name: string;
  65127. shader: string;
  65128. };
  65129. }
  65130. declare module BABYLON {
  65131. /**
  65132. * Extracts highlights from the image
  65133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65134. */
  65135. export class HighlightsPostProcess extends PostProcess {
  65136. /**
  65137. * Extracts highlights from the image
  65138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65139. * @param name The name of the effect.
  65140. * @param options The required width/height ratio to downsize to before computing the render pass.
  65141. * @param camera The camera to apply the render pass to.
  65142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65143. * @param engine The engine which the post process will be applied. (default: current engine)
  65144. * @param reusable If the post process can be reused on the same frame. (default: false)
  65145. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65146. */
  65147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65148. }
  65149. }
  65150. declare module BABYLON {
  65151. /** @hidden */
  65152. export var mrtFragmentDeclaration: {
  65153. name: string;
  65154. shader: string;
  65155. };
  65156. }
  65157. declare module BABYLON {
  65158. /** @hidden */
  65159. export var geometryPixelShader: {
  65160. name: string;
  65161. shader: string;
  65162. };
  65163. }
  65164. declare module BABYLON {
  65165. /** @hidden */
  65166. export var geometryVertexShader: {
  65167. name: string;
  65168. shader: string;
  65169. };
  65170. }
  65171. declare module BABYLON {
  65172. /** @hidden */
  65173. interface ISavedTransformationMatrix {
  65174. world: Matrix;
  65175. viewProjection: Matrix;
  65176. }
  65177. /**
  65178. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65179. */
  65180. export class GeometryBufferRenderer {
  65181. /**
  65182. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65183. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65184. */
  65185. static readonly POSITION_TEXTURE_TYPE: number;
  65186. /**
  65187. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65188. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65189. */
  65190. static readonly VELOCITY_TEXTURE_TYPE: number;
  65191. /**
  65192. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65193. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65194. */
  65195. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65196. /**
  65197. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65198. * in order to compute objects velocities when enableVelocity is set to "true"
  65199. * @hidden
  65200. */
  65201. _previousTransformationMatrices: {
  65202. [index: number]: ISavedTransformationMatrix;
  65203. };
  65204. /**
  65205. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65206. * in order to compute objects velocities when enableVelocity is set to "true"
  65207. * @hidden
  65208. */
  65209. _previousBonesTransformationMatrices: {
  65210. [index: number]: Float32Array;
  65211. };
  65212. /**
  65213. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65214. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65215. */
  65216. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65217. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65218. renderTransparentMeshes: boolean;
  65219. private _scene;
  65220. private _multiRenderTarget;
  65221. private _ratio;
  65222. private _enablePosition;
  65223. private _enableVelocity;
  65224. private _enableReflectivity;
  65225. private _positionIndex;
  65226. private _velocityIndex;
  65227. private _reflectivityIndex;
  65228. protected _effect: Effect;
  65229. protected _cachedDefines: string;
  65230. /**
  65231. * Set the render list (meshes to be rendered) used in the G buffer.
  65232. */
  65233. set renderList(meshes: Mesh[]);
  65234. /**
  65235. * Gets wether or not G buffer are supported by the running hardware.
  65236. * This requires draw buffer supports
  65237. */
  65238. get isSupported(): boolean;
  65239. /**
  65240. * Returns the index of the given texture type in the G-Buffer textures array
  65241. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65242. * @returns the index of the given texture type in the G-Buffer textures array
  65243. */
  65244. getTextureIndex(textureType: number): number;
  65245. /**
  65246. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65247. */
  65248. get enablePosition(): boolean;
  65249. /**
  65250. * Sets whether or not objects positions are enabled for the G buffer.
  65251. */
  65252. set enablePosition(enable: boolean);
  65253. /**
  65254. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65255. */
  65256. get enableVelocity(): boolean;
  65257. /**
  65258. * Sets wether or not objects velocities are enabled for the G buffer.
  65259. */
  65260. set enableVelocity(enable: boolean);
  65261. /**
  65262. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65263. */
  65264. get enableReflectivity(): boolean;
  65265. /**
  65266. * Sets wether or not objects roughness are enabled for the G buffer.
  65267. */
  65268. set enableReflectivity(enable: boolean);
  65269. /**
  65270. * Gets the scene associated with the buffer.
  65271. */
  65272. get scene(): Scene;
  65273. /**
  65274. * Gets the ratio used by the buffer during its creation.
  65275. * How big is the buffer related to the main canvas.
  65276. */
  65277. get ratio(): number;
  65278. /** @hidden */
  65279. static _SceneComponentInitialization: (scene: Scene) => void;
  65280. /**
  65281. * Creates a new G Buffer for the scene
  65282. * @param scene The scene the buffer belongs to
  65283. * @param ratio How big is the buffer related to the main canvas.
  65284. */
  65285. constructor(scene: Scene, ratio?: number);
  65286. /**
  65287. * Checks wether everything is ready to render a submesh to the G buffer.
  65288. * @param subMesh the submesh to check readiness for
  65289. * @param useInstances is the mesh drawn using instance or not
  65290. * @returns true if ready otherwise false
  65291. */
  65292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65293. /**
  65294. * Gets the current underlying G Buffer.
  65295. * @returns the buffer
  65296. */
  65297. getGBuffer(): MultiRenderTarget;
  65298. /**
  65299. * Gets the number of samples used to render the buffer (anti aliasing).
  65300. */
  65301. get samples(): number;
  65302. /**
  65303. * Sets the number of samples used to render the buffer (anti aliasing).
  65304. */
  65305. set samples(value: number);
  65306. /**
  65307. * Disposes the renderer and frees up associated resources.
  65308. */
  65309. dispose(): void;
  65310. protected _createRenderTargets(): void;
  65311. private _copyBonesTransformationMatrices;
  65312. }
  65313. }
  65314. declare module BABYLON {
  65315. interface Scene {
  65316. /** @hidden (Backing field) */
  65317. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65318. /**
  65319. * Gets or Sets the current geometry buffer associated to the scene.
  65320. */
  65321. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65322. /**
  65323. * Enables a GeometryBufferRender and associates it with the scene
  65324. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65325. * @returns the GeometryBufferRenderer
  65326. */
  65327. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65328. /**
  65329. * Disables the GeometryBufferRender associated with the scene
  65330. */
  65331. disableGeometryBufferRenderer(): void;
  65332. }
  65333. /**
  65334. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65335. * in several rendering techniques.
  65336. */
  65337. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65338. /**
  65339. * The component name helpful to identify the component in the list of scene components.
  65340. */
  65341. readonly name: string;
  65342. /**
  65343. * The scene the component belongs to.
  65344. */
  65345. scene: Scene;
  65346. /**
  65347. * Creates a new instance of the component for the given scene
  65348. * @param scene Defines the scene to register the component in
  65349. */
  65350. constructor(scene: Scene);
  65351. /**
  65352. * Registers the component in a given scene
  65353. */
  65354. register(): void;
  65355. /**
  65356. * Rebuilds the elements related to this component in case of
  65357. * context lost for instance.
  65358. */
  65359. rebuild(): void;
  65360. /**
  65361. * Disposes the component and the associated ressources
  65362. */
  65363. dispose(): void;
  65364. private _gatherRenderTargets;
  65365. }
  65366. }
  65367. declare module BABYLON {
  65368. /** @hidden */
  65369. export var motionBlurPixelShader: {
  65370. name: string;
  65371. shader: string;
  65372. };
  65373. }
  65374. declare module BABYLON {
  65375. /**
  65376. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65377. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65378. * As an example, all you have to do is to create the post-process:
  65379. * var mb = new BABYLON.MotionBlurPostProcess(
  65380. * 'mb', // The name of the effect.
  65381. * scene, // The scene containing the objects to blur according to their velocity.
  65382. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65383. * camera // The camera to apply the render pass to.
  65384. * );
  65385. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65386. */
  65387. export class MotionBlurPostProcess extends PostProcess {
  65388. /**
  65389. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65390. */
  65391. motionStrength: number;
  65392. /**
  65393. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65394. */
  65395. get motionBlurSamples(): number;
  65396. /**
  65397. * Sets the number of iterations to be used for motion blur quality
  65398. */
  65399. set motionBlurSamples(samples: number);
  65400. private _motionBlurSamples;
  65401. private _geometryBufferRenderer;
  65402. /**
  65403. * Creates a new instance MotionBlurPostProcess
  65404. * @param name The name of the effect.
  65405. * @param scene The scene containing the objects to blur according to their velocity.
  65406. * @param options The required width/height ratio to downsize to before computing the render pass.
  65407. * @param camera The camera to apply the render pass to.
  65408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65409. * @param engine The engine which the post process will be applied. (default: current engine)
  65410. * @param reusable If the post process can be reused on the same frame. (default: false)
  65411. * @param textureType Type of textures used when performing the post process. (default: 0)
  65412. * @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)
  65413. */
  65414. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65415. /**
  65416. * Excludes the given skinned mesh from computing bones velocities.
  65417. * 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.
  65418. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65419. */
  65420. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65421. /**
  65422. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65423. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65424. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65425. */
  65426. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65427. /**
  65428. * Disposes the post process.
  65429. * @param camera The camera to dispose the post process on.
  65430. */
  65431. dispose(camera?: Camera): void;
  65432. }
  65433. }
  65434. declare module BABYLON {
  65435. /** @hidden */
  65436. export var refractionPixelShader: {
  65437. name: string;
  65438. shader: string;
  65439. };
  65440. }
  65441. declare module BABYLON {
  65442. /**
  65443. * Post process which applies a refractin texture
  65444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65445. */
  65446. export class RefractionPostProcess extends PostProcess {
  65447. /** the base color of the refraction (used to taint the rendering) */
  65448. color: Color3;
  65449. /** simulated refraction depth */
  65450. depth: number;
  65451. /** the coefficient of the base color (0 to remove base color tainting) */
  65452. colorLevel: number;
  65453. private _refTexture;
  65454. private _ownRefractionTexture;
  65455. /**
  65456. * Gets or sets the refraction texture
  65457. * Please note that you are responsible for disposing the texture if you set it manually
  65458. */
  65459. get refractionTexture(): Texture;
  65460. set refractionTexture(value: Texture);
  65461. /**
  65462. * Initializes the RefractionPostProcess
  65463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65464. * @param name The name of the effect.
  65465. * @param refractionTextureUrl Url of the refraction texture to use
  65466. * @param color the base color of the refraction (used to taint the rendering)
  65467. * @param depth simulated refraction depth
  65468. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65469. * @param camera The camera to apply the render pass to.
  65470. * @param options The required width/height ratio to downsize to before computing the render pass.
  65471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65472. * @param engine The engine which the post process will be applied. (default: current engine)
  65473. * @param reusable If the post process can be reused on the same frame. (default: false)
  65474. */
  65475. constructor(name: string, refractionTextureUrl: string,
  65476. /** the base color of the refraction (used to taint the rendering) */
  65477. color: Color3,
  65478. /** simulated refraction depth */
  65479. depth: number,
  65480. /** the coefficient of the base color (0 to remove base color tainting) */
  65481. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65482. /**
  65483. * Disposes of the post process
  65484. * @param camera Camera to dispose post process on
  65485. */
  65486. dispose(camera: Camera): void;
  65487. }
  65488. }
  65489. declare module BABYLON {
  65490. /** @hidden */
  65491. export var sharpenPixelShader: {
  65492. name: string;
  65493. shader: string;
  65494. };
  65495. }
  65496. declare module BABYLON {
  65497. /**
  65498. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65499. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65500. */
  65501. export class SharpenPostProcess extends PostProcess {
  65502. /**
  65503. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65504. */
  65505. colorAmount: number;
  65506. /**
  65507. * How much sharpness should be applied (default: 0.3)
  65508. */
  65509. edgeAmount: number;
  65510. /**
  65511. * Creates a new instance ConvolutionPostProcess
  65512. * @param name The name of the effect.
  65513. * @param options The required width/height ratio to downsize to before computing the render pass.
  65514. * @param camera The camera to apply the render pass to.
  65515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65516. * @param engine The engine which the post process will be applied. (default: current engine)
  65517. * @param reusable If the post process can be reused on the same frame. (default: false)
  65518. * @param textureType Type of textures used when performing the post process. (default: 0)
  65519. * @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)
  65520. */
  65521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65522. }
  65523. }
  65524. declare module BABYLON {
  65525. /**
  65526. * PostProcessRenderPipeline
  65527. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65528. */
  65529. export class PostProcessRenderPipeline {
  65530. private engine;
  65531. private _renderEffects;
  65532. private _renderEffectsForIsolatedPass;
  65533. /**
  65534. * List of inspectable custom properties (used by the Inspector)
  65535. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65536. */
  65537. inspectableCustomProperties: IInspectable[];
  65538. /**
  65539. * @hidden
  65540. */
  65541. protected _cameras: Camera[];
  65542. /** @hidden */
  65543. _name: string;
  65544. /**
  65545. * Gets pipeline name
  65546. */
  65547. get name(): string;
  65548. /** Gets the list of attached cameras */
  65549. get cameras(): Camera[];
  65550. /**
  65551. * Initializes a PostProcessRenderPipeline
  65552. * @param engine engine to add the pipeline to
  65553. * @param name name of the pipeline
  65554. */
  65555. constructor(engine: Engine, name: string);
  65556. /**
  65557. * Gets the class name
  65558. * @returns "PostProcessRenderPipeline"
  65559. */
  65560. getClassName(): string;
  65561. /**
  65562. * If all the render effects in the pipeline are supported
  65563. */
  65564. get isSupported(): boolean;
  65565. /**
  65566. * Adds an effect to the pipeline
  65567. * @param renderEffect the effect to add
  65568. */
  65569. addEffect(renderEffect: PostProcessRenderEffect): void;
  65570. /** @hidden */
  65571. _rebuild(): void;
  65572. /** @hidden */
  65573. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65574. /** @hidden */
  65575. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65576. /** @hidden */
  65577. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65578. /** @hidden */
  65579. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65580. /** @hidden */
  65581. _attachCameras(cameras: Camera, unique: boolean): void;
  65582. /** @hidden */
  65583. _attachCameras(cameras: Camera[], unique: boolean): void;
  65584. /** @hidden */
  65585. _detachCameras(cameras: Camera): void;
  65586. /** @hidden */
  65587. _detachCameras(cameras: Nullable<Camera[]>): void;
  65588. /** @hidden */
  65589. _update(): void;
  65590. /** @hidden */
  65591. _reset(): void;
  65592. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65593. /**
  65594. * Disposes of the pipeline
  65595. */
  65596. dispose(): void;
  65597. }
  65598. }
  65599. declare module BABYLON {
  65600. /**
  65601. * PostProcessRenderPipelineManager class
  65602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65603. */
  65604. export class PostProcessRenderPipelineManager {
  65605. private _renderPipelines;
  65606. /**
  65607. * Initializes a PostProcessRenderPipelineManager
  65608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65609. */
  65610. constructor();
  65611. /**
  65612. * Gets the list of supported render pipelines
  65613. */
  65614. get supportedPipelines(): PostProcessRenderPipeline[];
  65615. /**
  65616. * Adds a pipeline to the manager
  65617. * @param renderPipeline The pipeline to add
  65618. */
  65619. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65620. /**
  65621. * Attaches a camera to the pipeline
  65622. * @param renderPipelineName The name of the pipeline to attach to
  65623. * @param cameras the camera to attach
  65624. * @param unique if the camera can be attached multiple times to the pipeline
  65625. */
  65626. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65627. /**
  65628. * Detaches a camera from the pipeline
  65629. * @param renderPipelineName The name of the pipeline to detach from
  65630. * @param cameras the camera to detach
  65631. */
  65632. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65633. /**
  65634. * Enables an effect by name on a pipeline
  65635. * @param renderPipelineName the name of the pipeline to enable the effect in
  65636. * @param renderEffectName the name of the effect to enable
  65637. * @param cameras the cameras that the effect should be enabled on
  65638. */
  65639. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65640. /**
  65641. * Disables an effect by name on a pipeline
  65642. * @param renderPipelineName the name of the pipeline to disable the effect in
  65643. * @param renderEffectName the name of the effect to disable
  65644. * @param cameras the cameras that the effect should be disabled on
  65645. */
  65646. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65647. /**
  65648. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65649. */
  65650. update(): void;
  65651. /** @hidden */
  65652. _rebuild(): void;
  65653. /**
  65654. * Disposes of the manager and pipelines
  65655. */
  65656. dispose(): void;
  65657. }
  65658. }
  65659. declare module BABYLON {
  65660. interface Scene {
  65661. /** @hidden (Backing field) */
  65662. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65663. /**
  65664. * Gets the postprocess render pipeline manager
  65665. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65666. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65667. */
  65668. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65669. }
  65670. /**
  65671. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65672. */
  65673. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65674. /**
  65675. * The component name helpfull to identify the component in the list of scene components.
  65676. */
  65677. readonly name: string;
  65678. /**
  65679. * The scene the component belongs to.
  65680. */
  65681. scene: Scene;
  65682. /**
  65683. * Creates a new instance of the component for the given scene
  65684. * @param scene Defines the scene to register the component in
  65685. */
  65686. constructor(scene: Scene);
  65687. /**
  65688. * Registers the component in a given scene
  65689. */
  65690. register(): void;
  65691. /**
  65692. * Rebuilds the elements related to this component in case of
  65693. * context lost for instance.
  65694. */
  65695. rebuild(): void;
  65696. /**
  65697. * Disposes the component and the associated ressources
  65698. */
  65699. dispose(): void;
  65700. private _gatherRenderTargets;
  65701. }
  65702. }
  65703. declare module BABYLON {
  65704. /**
  65705. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65706. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65707. */
  65708. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65709. private _scene;
  65710. private _camerasToBeAttached;
  65711. /**
  65712. * ID of the sharpen post process,
  65713. */
  65714. private readonly SharpenPostProcessId;
  65715. /**
  65716. * @ignore
  65717. * ID of the image processing post process;
  65718. */
  65719. readonly ImageProcessingPostProcessId: string;
  65720. /**
  65721. * @ignore
  65722. * ID of the Fast Approximate Anti-Aliasing post process;
  65723. */
  65724. readonly FxaaPostProcessId: string;
  65725. /**
  65726. * ID of the chromatic aberration post process,
  65727. */
  65728. private readonly ChromaticAberrationPostProcessId;
  65729. /**
  65730. * ID of the grain post process
  65731. */
  65732. private readonly GrainPostProcessId;
  65733. /**
  65734. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65735. */
  65736. sharpen: SharpenPostProcess;
  65737. private _sharpenEffect;
  65738. private bloom;
  65739. /**
  65740. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65741. */
  65742. depthOfField: DepthOfFieldEffect;
  65743. /**
  65744. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65745. */
  65746. fxaa: FxaaPostProcess;
  65747. /**
  65748. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65749. */
  65750. imageProcessing: ImageProcessingPostProcess;
  65751. /**
  65752. * Chromatic aberration post process which will shift rgb colors in the image
  65753. */
  65754. chromaticAberration: ChromaticAberrationPostProcess;
  65755. private _chromaticAberrationEffect;
  65756. /**
  65757. * Grain post process which add noise to the image
  65758. */
  65759. grain: GrainPostProcess;
  65760. private _grainEffect;
  65761. /**
  65762. * Glow post process which adds a glow to emissive areas of the image
  65763. */
  65764. private _glowLayer;
  65765. /**
  65766. * Animations which can be used to tweak settings over a period of time
  65767. */
  65768. animations: Animation[];
  65769. private _imageProcessingConfigurationObserver;
  65770. private _sharpenEnabled;
  65771. private _bloomEnabled;
  65772. private _depthOfFieldEnabled;
  65773. private _depthOfFieldBlurLevel;
  65774. private _fxaaEnabled;
  65775. private _imageProcessingEnabled;
  65776. private _defaultPipelineTextureType;
  65777. private _bloomScale;
  65778. private _chromaticAberrationEnabled;
  65779. private _grainEnabled;
  65780. private _buildAllowed;
  65781. /**
  65782. * Gets active scene
  65783. */
  65784. get scene(): Scene;
  65785. /**
  65786. * Enable or disable the sharpen process from the pipeline
  65787. */
  65788. set sharpenEnabled(enabled: boolean);
  65789. get sharpenEnabled(): boolean;
  65790. private _resizeObserver;
  65791. private _hardwareScaleLevel;
  65792. private _bloomKernel;
  65793. /**
  65794. * Specifies the size of the bloom blur kernel, relative to the final output size
  65795. */
  65796. get bloomKernel(): number;
  65797. set bloomKernel(value: number);
  65798. /**
  65799. * Specifies the weight of the bloom in the final rendering
  65800. */
  65801. private _bloomWeight;
  65802. /**
  65803. * Specifies the luma threshold for the area that will be blurred by the bloom
  65804. */
  65805. private _bloomThreshold;
  65806. private _hdr;
  65807. /**
  65808. * The strength of the bloom.
  65809. */
  65810. set bloomWeight(value: number);
  65811. get bloomWeight(): number;
  65812. /**
  65813. * The strength of the bloom.
  65814. */
  65815. set bloomThreshold(value: number);
  65816. get bloomThreshold(): number;
  65817. /**
  65818. * The scale of the bloom, lower value will provide better performance.
  65819. */
  65820. set bloomScale(value: number);
  65821. get bloomScale(): number;
  65822. /**
  65823. * Enable or disable the bloom from the pipeline
  65824. */
  65825. set bloomEnabled(enabled: boolean);
  65826. get bloomEnabled(): boolean;
  65827. private _rebuildBloom;
  65828. /**
  65829. * If the depth of field is enabled.
  65830. */
  65831. get depthOfFieldEnabled(): boolean;
  65832. set depthOfFieldEnabled(enabled: boolean);
  65833. /**
  65834. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65835. */
  65836. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65837. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65838. /**
  65839. * If the anti aliasing is enabled.
  65840. */
  65841. set fxaaEnabled(enabled: boolean);
  65842. get fxaaEnabled(): boolean;
  65843. private _samples;
  65844. /**
  65845. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65846. */
  65847. set samples(sampleCount: number);
  65848. get samples(): number;
  65849. /**
  65850. * If image processing is enabled.
  65851. */
  65852. set imageProcessingEnabled(enabled: boolean);
  65853. get imageProcessingEnabled(): boolean;
  65854. /**
  65855. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65856. */
  65857. set glowLayerEnabled(enabled: boolean);
  65858. get glowLayerEnabled(): boolean;
  65859. /**
  65860. * Gets the glow layer (or null if not defined)
  65861. */
  65862. get glowLayer(): Nullable<GlowLayer>;
  65863. /**
  65864. * Enable or disable the chromaticAberration process from the pipeline
  65865. */
  65866. set chromaticAberrationEnabled(enabled: boolean);
  65867. get chromaticAberrationEnabled(): boolean;
  65868. /**
  65869. * Enable or disable the grain process from the pipeline
  65870. */
  65871. set grainEnabled(enabled: boolean);
  65872. get grainEnabled(): boolean;
  65873. /**
  65874. * @constructor
  65875. * @param name - The rendering pipeline name (default: "")
  65876. * @param hdr - If high dynamic range textures should be used (default: true)
  65877. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65878. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65879. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65880. */
  65881. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65882. /**
  65883. * Get the class name
  65884. * @returns "DefaultRenderingPipeline"
  65885. */
  65886. getClassName(): string;
  65887. /**
  65888. * Force the compilation of the entire pipeline.
  65889. */
  65890. prepare(): void;
  65891. private _hasCleared;
  65892. private _prevPostProcess;
  65893. private _prevPrevPostProcess;
  65894. private _setAutoClearAndTextureSharing;
  65895. private _depthOfFieldSceneObserver;
  65896. private _buildPipeline;
  65897. private _disposePostProcesses;
  65898. /**
  65899. * Adds a camera to the pipeline
  65900. * @param camera the camera to be added
  65901. */
  65902. addCamera(camera: Camera): void;
  65903. /**
  65904. * Removes a camera from the pipeline
  65905. * @param camera the camera to remove
  65906. */
  65907. removeCamera(camera: Camera): void;
  65908. /**
  65909. * Dispose of the pipeline and stop all post processes
  65910. */
  65911. dispose(): void;
  65912. /**
  65913. * Serialize the rendering pipeline (Used when exporting)
  65914. * @returns the serialized object
  65915. */
  65916. serialize(): any;
  65917. /**
  65918. * Parse the serialized pipeline
  65919. * @param source Source pipeline.
  65920. * @param scene The scene to load the pipeline to.
  65921. * @param rootUrl The URL of the serialized pipeline.
  65922. * @returns An instantiated pipeline from the serialized object.
  65923. */
  65924. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65925. }
  65926. }
  65927. declare module BABYLON {
  65928. /** @hidden */
  65929. export var lensHighlightsPixelShader: {
  65930. name: string;
  65931. shader: string;
  65932. };
  65933. }
  65934. declare module BABYLON {
  65935. /** @hidden */
  65936. export var depthOfFieldPixelShader: {
  65937. name: string;
  65938. shader: string;
  65939. };
  65940. }
  65941. declare module BABYLON {
  65942. /**
  65943. * BABYLON.JS Chromatic Aberration GLSL Shader
  65944. * Author: Olivier Guyot
  65945. * Separates very slightly R, G and B colors on the edges of the screen
  65946. * Inspired by Francois Tarlier & Martins Upitis
  65947. */
  65948. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65949. /**
  65950. * @ignore
  65951. * The chromatic aberration PostProcess id in the pipeline
  65952. */
  65953. LensChromaticAberrationEffect: string;
  65954. /**
  65955. * @ignore
  65956. * The highlights enhancing PostProcess id in the pipeline
  65957. */
  65958. HighlightsEnhancingEffect: string;
  65959. /**
  65960. * @ignore
  65961. * The depth-of-field PostProcess id in the pipeline
  65962. */
  65963. LensDepthOfFieldEffect: string;
  65964. private _scene;
  65965. private _depthTexture;
  65966. private _grainTexture;
  65967. private _chromaticAberrationPostProcess;
  65968. private _highlightsPostProcess;
  65969. private _depthOfFieldPostProcess;
  65970. private _edgeBlur;
  65971. private _grainAmount;
  65972. private _chromaticAberration;
  65973. private _distortion;
  65974. private _highlightsGain;
  65975. private _highlightsThreshold;
  65976. private _dofDistance;
  65977. private _dofAperture;
  65978. private _dofDarken;
  65979. private _dofPentagon;
  65980. private _blurNoise;
  65981. /**
  65982. * @constructor
  65983. *
  65984. * Effect parameters are as follow:
  65985. * {
  65986. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65987. * edge_blur: number; // from 0 to x (1 for realism)
  65988. * distortion: number; // from 0 to x (1 for realism)
  65989. * grain_amount: number; // from 0 to 1
  65990. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65991. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65992. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65993. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65994. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65995. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65996. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65997. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65998. * }
  65999. * Note: if an effect parameter is unset, effect is disabled
  66000. *
  66001. * @param name The rendering pipeline name
  66002. * @param parameters - An object containing all parameters (see above)
  66003. * @param scene The scene linked to this pipeline
  66004. * @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)
  66005. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66006. */
  66007. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66008. /**
  66009. * Get the class name
  66010. * @returns "LensRenderingPipeline"
  66011. */
  66012. getClassName(): string;
  66013. /**
  66014. * Gets associated scene
  66015. */
  66016. get scene(): Scene;
  66017. /**
  66018. * Gets or sets the edge blur
  66019. */
  66020. get edgeBlur(): number;
  66021. set edgeBlur(value: number);
  66022. /**
  66023. * Gets or sets the grain amount
  66024. */
  66025. get grainAmount(): number;
  66026. set grainAmount(value: number);
  66027. /**
  66028. * Gets or sets the chromatic aberration amount
  66029. */
  66030. get chromaticAberration(): number;
  66031. set chromaticAberration(value: number);
  66032. /**
  66033. * Gets or sets the depth of field aperture
  66034. */
  66035. get dofAperture(): number;
  66036. set dofAperture(value: number);
  66037. /**
  66038. * Gets or sets the edge distortion
  66039. */
  66040. get edgeDistortion(): number;
  66041. set edgeDistortion(value: number);
  66042. /**
  66043. * Gets or sets the depth of field distortion
  66044. */
  66045. get dofDistortion(): number;
  66046. set dofDistortion(value: number);
  66047. /**
  66048. * Gets or sets the darken out of focus amount
  66049. */
  66050. get darkenOutOfFocus(): number;
  66051. set darkenOutOfFocus(value: number);
  66052. /**
  66053. * Gets or sets a boolean indicating if blur noise is enabled
  66054. */
  66055. get blurNoise(): boolean;
  66056. set blurNoise(value: boolean);
  66057. /**
  66058. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66059. */
  66060. get pentagonBokeh(): boolean;
  66061. set pentagonBokeh(value: boolean);
  66062. /**
  66063. * Gets or sets the highlight grain amount
  66064. */
  66065. get highlightsGain(): number;
  66066. set highlightsGain(value: number);
  66067. /**
  66068. * Gets or sets the highlight threshold
  66069. */
  66070. get highlightsThreshold(): number;
  66071. set highlightsThreshold(value: number);
  66072. /**
  66073. * Sets the amount of blur at the edges
  66074. * @param amount blur amount
  66075. */
  66076. setEdgeBlur(amount: number): void;
  66077. /**
  66078. * Sets edge blur to 0
  66079. */
  66080. disableEdgeBlur(): void;
  66081. /**
  66082. * Sets the amout of grain
  66083. * @param amount Amount of grain
  66084. */
  66085. setGrainAmount(amount: number): void;
  66086. /**
  66087. * Set grain amount to 0
  66088. */
  66089. disableGrain(): void;
  66090. /**
  66091. * Sets the chromatic aberration amount
  66092. * @param amount amount of chromatic aberration
  66093. */
  66094. setChromaticAberration(amount: number): void;
  66095. /**
  66096. * Sets chromatic aberration amount to 0
  66097. */
  66098. disableChromaticAberration(): void;
  66099. /**
  66100. * Sets the EdgeDistortion amount
  66101. * @param amount amount of EdgeDistortion
  66102. */
  66103. setEdgeDistortion(amount: number): void;
  66104. /**
  66105. * Sets edge distortion to 0
  66106. */
  66107. disableEdgeDistortion(): void;
  66108. /**
  66109. * Sets the FocusDistance amount
  66110. * @param amount amount of FocusDistance
  66111. */
  66112. setFocusDistance(amount: number): void;
  66113. /**
  66114. * Disables depth of field
  66115. */
  66116. disableDepthOfField(): void;
  66117. /**
  66118. * Sets the Aperture amount
  66119. * @param amount amount of Aperture
  66120. */
  66121. setAperture(amount: number): void;
  66122. /**
  66123. * Sets the DarkenOutOfFocus amount
  66124. * @param amount amount of DarkenOutOfFocus
  66125. */
  66126. setDarkenOutOfFocus(amount: number): void;
  66127. private _pentagonBokehIsEnabled;
  66128. /**
  66129. * Creates a pentagon bokeh effect
  66130. */
  66131. enablePentagonBokeh(): void;
  66132. /**
  66133. * Disables the pentagon bokeh effect
  66134. */
  66135. disablePentagonBokeh(): void;
  66136. /**
  66137. * Enables noise blur
  66138. */
  66139. enableNoiseBlur(): void;
  66140. /**
  66141. * Disables noise blur
  66142. */
  66143. disableNoiseBlur(): void;
  66144. /**
  66145. * Sets the HighlightsGain amount
  66146. * @param amount amount of HighlightsGain
  66147. */
  66148. setHighlightsGain(amount: number): void;
  66149. /**
  66150. * Sets the HighlightsThreshold amount
  66151. * @param amount amount of HighlightsThreshold
  66152. */
  66153. setHighlightsThreshold(amount: number): void;
  66154. /**
  66155. * Disables highlights
  66156. */
  66157. disableHighlights(): void;
  66158. /**
  66159. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66160. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66161. */
  66162. dispose(disableDepthRender?: boolean): void;
  66163. private _createChromaticAberrationPostProcess;
  66164. private _createHighlightsPostProcess;
  66165. private _createDepthOfFieldPostProcess;
  66166. private _createGrainTexture;
  66167. }
  66168. }
  66169. declare module BABYLON {
  66170. /** @hidden */
  66171. export var ssao2PixelShader: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module BABYLON {
  66177. /** @hidden */
  66178. export var ssaoCombinePixelShader: {
  66179. name: string;
  66180. shader: string;
  66181. };
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * Render pipeline to produce ssao effect
  66186. */
  66187. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66188. /**
  66189. * @ignore
  66190. * The PassPostProcess id in the pipeline that contains the original scene color
  66191. */
  66192. SSAOOriginalSceneColorEffect: string;
  66193. /**
  66194. * @ignore
  66195. * The SSAO PostProcess id in the pipeline
  66196. */
  66197. SSAORenderEffect: string;
  66198. /**
  66199. * @ignore
  66200. * The horizontal blur PostProcess id in the pipeline
  66201. */
  66202. SSAOBlurHRenderEffect: string;
  66203. /**
  66204. * @ignore
  66205. * The vertical blur PostProcess id in the pipeline
  66206. */
  66207. SSAOBlurVRenderEffect: string;
  66208. /**
  66209. * @ignore
  66210. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66211. */
  66212. SSAOCombineRenderEffect: string;
  66213. /**
  66214. * The output strength of the SSAO post-process. Default value is 1.0.
  66215. */
  66216. totalStrength: number;
  66217. /**
  66218. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66219. */
  66220. maxZ: number;
  66221. /**
  66222. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66223. */
  66224. minZAspect: number;
  66225. private _samples;
  66226. /**
  66227. * Number of samples used for the SSAO calculations. Default value is 8
  66228. */
  66229. set samples(n: number);
  66230. get samples(): number;
  66231. private _textureSamples;
  66232. /**
  66233. * Number of samples to use for antialiasing
  66234. */
  66235. set textureSamples(n: number);
  66236. get textureSamples(): number;
  66237. /**
  66238. * Ratio object used for SSAO ratio and blur ratio
  66239. */
  66240. private _ratio;
  66241. /**
  66242. * Dynamically generated sphere sampler.
  66243. */
  66244. private _sampleSphere;
  66245. /**
  66246. * Blur filter offsets
  66247. */
  66248. private _samplerOffsets;
  66249. private _expensiveBlur;
  66250. /**
  66251. * If bilateral blur should be used
  66252. */
  66253. set expensiveBlur(b: boolean);
  66254. get expensiveBlur(): boolean;
  66255. /**
  66256. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66257. */
  66258. radius: number;
  66259. /**
  66260. * The base color of the SSAO post-process
  66261. * The final result is "base + ssao" between [0, 1]
  66262. */
  66263. base: number;
  66264. /**
  66265. * Support test.
  66266. */
  66267. static get IsSupported(): boolean;
  66268. private _scene;
  66269. private _depthTexture;
  66270. private _normalTexture;
  66271. private _randomTexture;
  66272. private _originalColorPostProcess;
  66273. private _ssaoPostProcess;
  66274. private _blurHPostProcess;
  66275. private _blurVPostProcess;
  66276. private _ssaoCombinePostProcess;
  66277. /**
  66278. * Gets active scene
  66279. */
  66280. get scene(): Scene;
  66281. /**
  66282. * @constructor
  66283. * @param name The rendering pipeline name
  66284. * @param scene The scene linked to this pipeline
  66285. * @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 }
  66286. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66287. */
  66288. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66289. /**
  66290. * Get the class name
  66291. * @returns "SSAO2RenderingPipeline"
  66292. */
  66293. getClassName(): string;
  66294. /**
  66295. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66296. */
  66297. dispose(disableGeometryBufferRenderer?: boolean): void;
  66298. private _createBlurPostProcess;
  66299. /** @hidden */
  66300. _rebuild(): void;
  66301. private _bits;
  66302. private _radicalInverse_VdC;
  66303. private _hammersley;
  66304. private _hemisphereSample_uniform;
  66305. private _generateHemisphere;
  66306. private _createSSAOPostProcess;
  66307. private _createSSAOCombinePostProcess;
  66308. private _createRandomTexture;
  66309. /**
  66310. * Serialize the rendering pipeline (Used when exporting)
  66311. * @returns the serialized object
  66312. */
  66313. serialize(): any;
  66314. /**
  66315. * Parse the serialized pipeline
  66316. * @param source Source pipeline.
  66317. * @param scene The scene to load the pipeline to.
  66318. * @param rootUrl The URL of the serialized pipeline.
  66319. * @returns An instantiated pipeline from the serialized object.
  66320. */
  66321. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66322. }
  66323. }
  66324. declare module BABYLON {
  66325. /** @hidden */
  66326. export var ssaoPixelShader: {
  66327. name: string;
  66328. shader: string;
  66329. };
  66330. }
  66331. declare module BABYLON {
  66332. /**
  66333. * Render pipeline to produce ssao effect
  66334. */
  66335. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66336. /**
  66337. * @ignore
  66338. * The PassPostProcess id in the pipeline that contains the original scene color
  66339. */
  66340. SSAOOriginalSceneColorEffect: string;
  66341. /**
  66342. * @ignore
  66343. * The SSAO PostProcess id in the pipeline
  66344. */
  66345. SSAORenderEffect: string;
  66346. /**
  66347. * @ignore
  66348. * The horizontal blur PostProcess id in the pipeline
  66349. */
  66350. SSAOBlurHRenderEffect: string;
  66351. /**
  66352. * @ignore
  66353. * The vertical blur PostProcess id in the pipeline
  66354. */
  66355. SSAOBlurVRenderEffect: string;
  66356. /**
  66357. * @ignore
  66358. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66359. */
  66360. SSAOCombineRenderEffect: string;
  66361. /**
  66362. * The output strength of the SSAO post-process. Default value is 1.0.
  66363. */
  66364. totalStrength: number;
  66365. /**
  66366. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66367. */
  66368. radius: number;
  66369. /**
  66370. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66371. * Must not be equal to fallOff and superior to fallOff.
  66372. * Default value is 0.0075
  66373. */
  66374. area: number;
  66375. /**
  66376. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66377. * Must not be equal to area and inferior to area.
  66378. * Default value is 0.000001
  66379. */
  66380. fallOff: number;
  66381. /**
  66382. * The base color of the SSAO post-process
  66383. * The final result is "base + ssao" between [0, 1]
  66384. */
  66385. base: number;
  66386. private _scene;
  66387. private _depthTexture;
  66388. private _randomTexture;
  66389. private _originalColorPostProcess;
  66390. private _ssaoPostProcess;
  66391. private _blurHPostProcess;
  66392. private _blurVPostProcess;
  66393. private _ssaoCombinePostProcess;
  66394. private _firstUpdate;
  66395. /**
  66396. * Gets active scene
  66397. */
  66398. get scene(): Scene;
  66399. /**
  66400. * @constructor
  66401. * @param name - The rendering pipeline name
  66402. * @param scene - The scene linked to this pipeline
  66403. * @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 }
  66404. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66405. */
  66406. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66407. /**
  66408. * Get the class name
  66409. * @returns "SSAORenderingPipeline"
  66410. */
  66411. getClassName(): string;
  66412. /**
  66413. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66414. */
  66415. dispose(disableDepthRender?: boolean): void;
  66416. private _createBlurPostProcess;
  66417. /** @hidden */
  66418. _rebuild(): void;
  66419. private _createSSAOPostProcess;
  66420. private _createSSAOCombinePostProcess;
  66421. private _createRandomTexture;
  66422. }
  66423. }
  66424. declare module BABYLON {
  66425. /** @hidden */
  66426. export var screenSpaceReflectionPixelShader: {
  66427. name: string;
  66428. shader: string;
  66429. };
  66430. }
  66431. declare module BABYLON {
  66432. /**
  66433. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66434. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66435. */
  66436. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66437. /**
  66438. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66439. */
  66440. threshold: number;
  66441. /**
  66442. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66443. */
  66444. strength: number;
  66445. /**
  66446. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66447. */
  66448. reflectionSpecularFalloffExponent: number;
  66449. /**
  66450. * 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]
  66451. */
  66452. step: number;
  66453. /**
  66454. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66455. */
  66456. roughnessFactor: number;
  66457. private _geometryBufferRenderer;
  66458. private _enableSmoothReflections;
  66459. private _reflectionSamples;
  66460. private _smoothSteps;
  66461. /**
  66462. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66463. * @param name The name of the effect.
  66464. * @param scene The scene containing the objects to calculate reflections.
  66465. * @param options The required width/height ratio to downsize to before computing the render pass.
  66466. * @param camera The camera to apply the render pass to.
  66467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66468. * @param engine The engine which the post process will be applied. (default: current engine)
  66469. * @param reusable If the post process can be reused on the same frame. (default: false)
  66470. * @param textureType Type of textures used when performing the post process. (default: 0)
  66471. * @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)
  66472. */
  66473. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66474. /**
  66475. * Gets wether or not smoothing reflections is enabled.
  66476. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66477. */
  66478. get enableSmoothReflections(): boolean;
  66479. /**
  66480. * Sets wether or not smoothing reflections is enabled.
  66481. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66482. */
  66483. set enableSmoothReflections(enabled: boolean);
  66484. /**
  66485. * Gets the number of samples taken while computing reflections. More samples count is high,
  66486. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66487. */
  66488. get reflectionSamples(): number;
  66489. /**
  66490. * Sets the number of samples taken while computing reflections. More samples count is high,
  66491. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66492. */
  66493. set reflectionSamples(samples: number);
  66494. /**
  66495. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66496. * more the post-process will require GPU power and can generate a drop in FPS.
  66497. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66498. */
  66499. get smoothSteps(): number;
  66500. set smoothSteps(steps: number);
  66501. private _updateEffectDefines;
  66502. }
  66503. }
  66504. declare module BABYLON {
  66505. /** @hidden */
  66506. export var standardPixelShader: {
  66507. name: string;
  66508. shader: string;
  66509. };
  66510. }
  66511. declare module BABYLON {
  66512. /**
  66513. * Standard rendering pipeline
  66514. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66515. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66516. */
  66517. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66518. /**
  66519. * Public members
  66520. */
  66521. /**
  66522. * Post-process which contains the original scene color before the pipeline applies all the effects
  66523. */
  66524. originalPostProcess: Nullable<PostProcess>;
  66525. /**
  66526. * Post-process used to down scale an image x4
  66527. */
  66528. downSampleX4PostProcess: Nullable<PostProcess>;
  66529. /**
  66530. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66531. */
  66532. brightPassPostProcess: Nullable<PostProcess>;
  66533. /**
  66534. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66535. */
  66536. blurHPostProcesses: PostProcess[];
  66537. /**
  66538. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66539. */
  66540. blurVPostProcesses: PostProcess[];
  66541. /**
  66542. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66543. */
  66544. textureAdderPostProcess: Nullable<PostProcess>;
  66545. /**
  66546. * Post-process used to create volumetric lighting effect
  66547. */
  66548. volumetricLightPostProcess: Nullable<PostProcess>;
  66549. /**
  66550. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66551. */
  66552. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66553. /**
  66554. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66555. */
  66556. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66557. /**
  66558. * Post-process used to merge the volumetric light effect and the real scene color
  66559. */
  66560. volumetricLightMergePostProces: Nullable<PostProcess>;
  66561. /**
  66562. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66563. */
  66564. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66565. /**
  66566. * Base post-process used to calculate the average luminance of the final image for HDR
  66567. */
  66568. luminancePostProcess: Nullable<PostProcess>;
  66569. /**
  66570. * Post-processes used to create down sample post-processes in order to get
  66571. * the average luminance of the final image for HDR
  66572. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66573. */
  66574. luminanceDownSamplePostProcesses: PostProcess[];
  66575. /**
  66576. * Post-process used to create a HDR effect (light adaptation)
  66577. */
  66578. hdrPostProcess: Nullable<PostProcess>;
  66579. /**
  66580. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66581. */
  66582. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66583. /**
  66584. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66585. */
  66586. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66587. /**
  66588. * Post-process used to merge the final HDR post-process and the real scene color
  66589. */
  66590. hdrFinalPostProcess: Nullable<PostProcess>;
  66591. /**
  66592. * Post-process used to create a lens flare effect
  66593. */
  66594. lensFlarePostProcess: Nullable<PostProcess>;
  66595. /**
  66596. * Post-process that merges the result of the lens flare post-process and the real scene color
  66597. */
  66598. lensFlareComposePostProcess: Nullable<PostProcess>;
  66599. /**
  66600. * Post-process used to create a motion blur effect
  66601. */
  66602. motionBlurPostProcess: Nullable<PostProcess>;
  66603. /**
  66604. * Post-process used to create a depth of field effect
  66605. */
  66606. depthOfFieldPostProcess: Nullable<PostProcess>;
  66607. /**
  66608. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66609. */
  66610. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66611. /**
  66612. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66613. */
  66614. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66615. /**
  66616. * Represents the brightness threshold in order to configure the illuminated surfaces
  66617. */
  66618. brightThreshold: number;
  66619. /**
  66620. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66621. */
  66622. blurWidth: number;
  66623. /**
  66624. * Sets if the blur for highlighted surfaces must be only horizontal
  66625. */
  66626. horizontalBlur: boolean;
  66627. /**
  66628. * Gets the overall exposure used by the pipeline
  66629. */
  66630. get exposure(): number;
  66631. /**
  66632. * Sets the overall exposure used by the pipeline
  66633. */
  66634. set exposure(value: number);
  66635. /**
  66636. * Texture used typically to simulate "dirty" on camera lens
  66637. */
  66638. lensTexture: Nullable<Texture>;
  66639. /**
  66640. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66641. */
  66642. volumetricLightCoefficient: number;
  66643. /**
  66644. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66645. */
  66646. volumetricLightPower: number;
  66647. /**
  66648. * Used the set the blur intensity to smooth the volumetric lights
  66649. */
  66650. volumetricLightBlurScale: number;
  66651. /**
  66652. * Light (spot or directional) used to generate the volumetric lights rays
  66653. * The source light must have a shadow generate so the pipeline can get its
  66654. * depth map
  66655. */
  66656. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66657. /**
  66658. * For eye adaptation, represents the minimum luminance the eye can see
  66659. */
  66660. hdrMinimumLuminance: number;
  66661. /**
  66662. * For eye adaptation, represents the decrease luminance speed
  66663. */
  66664. hdrDecreaseRate: number;
  66665. /**
  66666. * For eye adaptation, represents the increase luminance speed
  66667. */
  66668. hdrIncreaseRate: number;
  66669. /**
  66670. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66671. */
  66672. get hdrAutoExposure(): boolean;
  66673. /**
  66674. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66675. */
  66676. set hdrAutoExposure(value: boolean);
  66677. /**
  66678. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66679. */
  66680. lensColorTexture: Nullable<Texture>;
  66681. /**
  66682. * The overall strengh for the lens flare effect
  66683. */
  66684. lensFlareStrength: number;
  66685. /**
  66686. * Dispersion coefficient for lens flare ghosts
  66687. */
  66688. lensFlareGhostDispersal: number;
  66689. /**
  66690. * Main lens flare halo width
  66691. */
  66692. lensFlareHaloWidth: number;
  66693. /**
  66694. * Based on the lens distortion effect, defines how much the lens flare result
  66695. * is distorted
  66696. */
  66697. lensFlareDistortionStrength: number;
  66698. /**
  66699. * Configures the blur intensity used for for lens flare (halo)
  66700. */
  66701. lensFlareBlurWidth: number;
  66702. /**
  66703. * Lens star texture must be used to simulate rays on the flares and is available
  66704. * in the documentation
  66705. */
  66706. lensStarTexture: Nullable<Texture>;
  66707. /**
  66708. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66709. * flare effect by taking account of the dirt texture
  66710. */
  66711. lensFlareDirtTexture: Nullable<Texture>;
  66712. /**
  66713. * Represents the focal length for the depth of field effect
  66714. */
  66715. depthOfFieldDistance: number;
  66716. /**
  66717. * Represents the blur intensity for the blurred part of the depth of field effect
  66718. */
  66719. depthOfFieldBlurWidth: number;
  66720. /**
  66721. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66722. */
  66723. get motionStrength(): number;
  66724. /**
  66725. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66726. */
  66727. set motionStrength(strength: number);
  66728. /**
  66729. * Gets wether or not the motion blur post-process is object based or screen based.
  66730. */
  66731. get objectBasedMotionBlur(): boolean;
  66732. /**
  66733. * Sets wether or not the motion blur post-process should be object based or screen based
  66734. */
  66735. set objectBasedMotionBlur(value: boolean);
  66736. /**
  66737. * List of animations for the pipeline (IAnimatable implementation)
  66738. */
  66739. animations: Animation[];
  66740. /**
  66741. * Private members
  66742. */
  66743. private _scene;
  66744. private _currentDepthOfFieldSource;
  66745. private _basePostProcess;
  66746. private _fixedExposure;
  66747. private _currentExposure;
  66748. private _hdrAutoExposure;
  66749. private _hdrCurrentLuminance;
  66750. private _motionStrength;
  66751. private _isObjectBasedMotionBlur;
  66752. private _floatTextureType;
  66753. private _camerasToBeAttached;
  66754. private _ratio;
  66755. private _bloomEnabled;
  66756. private _depthOfFieldEnabled;
  66757. private _vlsEnabled;
  66758. private _lensFlareEnabled;
  66759. private _hdrEnabled;
  66760. private _motionBlurEnabled;
  66761. private _fxaaEnabled;
  66762. private _screenSpaceReflectionsEnabled;
  66763. private _motionBlurSamples;
  66764. private _volumetricLightStepsCount;
  66765. private _samples;
  66766. /**
  66767. * @ignore
  66768. * Specifies if the bloom pipeline is enabled
  66769. */
  66770. get BloomEnabled(): boolean;
  66771. set BloomEnabled(enabled: boolean);
  66772. /**
  66773. * @ignore
  66774. * Specifies if the depth of field pipeline is enabed
  66775. */
  66776. get DepthOfFieldEnabled(): boolean;
  66777. set DepthOfFieldEnabled(enabled: boolean);
  66778. /**
  66779. * @ignore
  66780. * Specifies if the lens flare pipeline is enabed
  66781. */
  66782. get LensFlareEnabled(): boolean;
  66783. set LensFlareEnabled(enabled: boolean);
  66784. /**
  66785. * @ignore
  66786. * Specifies if the HDR pipeline is enabled
  66787. */
  66788. get HDREnabled(): boolean;
  66789. set HDREnabled(enabled: boolean);
  66790. /**
  66791. * @ignore
  66792. * Specifies if the volumetric lights scattering effect is enabled
  66793. */
  66794. get VLSEnabled(): boolean;
  66795. set VLSEnabled(enabled: boolean);
  66796. /**
  66797. * @ignore
  66798. * Specifies if the motion blur effect is enabled
  66799. */
  66800. get MotionBlurEnabled(): boolean;
  66801. set MotionBlurEnabled(enabled: boolean);
  66802. /**
  66803. * Specifies if anti-aliasing is enabled
  66804. */
  66805. get fxaaEnabled(): boolean;
  66806. set fxaaEnabled(enabled: boolean);
  66807. /**
  66808. * Specifies if screen space reflections are enabled.
  66809. */
  66810. get screenSpaceReflectionsEnabled(): boolean;
  66811. set screenSpaceReflectionsEnabled(enabled: boolean);
  66812. /**
  66813. * Specifies the number of steps used to calculate the volumetric lights
  66814. * Typically in interval [50, 200]
  66815. */
  66816. get volumetricLightStepsCount(): number;
  66817. set volumetricLightStepsCount(count: number);
  66818. /**
  66819. * Specifies the number of samples used for the motion blur effect
  66820. * Typically in interval [16, 64]
  66821. */
  66822. get motionBlurSamples(): number;
  66823. set motionBlurSamples(samples: number);
  66824. /**
  66825. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66826. */
  66827. get samples(): number;
  66828. set samples(sampleCount: number);
  66829. /**
  66830. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66831. * @constructor
  66832. * @param name The rendering pipeline name
  66833. * @param scene The scene linked to this pipeline
  66834. * @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)
  66835. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66836. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66837. */
  66838. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66839. private _buildPipeline;
  66840. private _createDownSampleX4PostProcess;
  66841. private _createBrightPassPostProcess;
  66842. private _createBlurPostProcesses;
  66843. private _createTextureAdderPostProcess;
  66844. private _createVolumetricLightPostProcess;
  66845. private _createLuminancePostProcesses;
  66846. private _createHdrPostProcess;
  66847. private _createLensFlarePostProcess;
  66848. private _createDepthOfFieldPostProcess;
  66849. private _createMotionBlurPostProcess;
  66850. private _getDepthTexture;
  66851. private _disposePostProcesses;
  66852. /**
  66853. * Dispose of the pipeline and stop all post processes
  66854. */
  66855. dispose(): void;
  66856. /**
  66857. * Serialize the rendering pipeline (Used when exporting)
  66858. * @returns the serialized object
  66859. */
  66860. serialize(): any;
  66861. /**
  66862. * Parse the serialized pipeline
  66863. * @param source Source pipeline.
  66864. * @param scene The scene to load the pipeline to.
  66865. * @param rootUrl The URL of the serialized pipeline.
  66866. * @returns An instantiated pipeline from the serialized object.
  66867. */
  66868. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66869. /**
  66870. * Luminance steps
  66871. */
  66872. static LuminanceSteps: number;
  66873. }
  66874. }
  66875. declare module BABYLON {
  66876. /** @hidden */
  66877. export var tonemapPixelShader: {
  66878. name: string;
  66879. shader: string;
  66880. };
  66881. }
  66882. declare module BABYLON {
  66883. /** Defines operator used for tonemapping */
  66884. export enum TonemappingOperator {
  66885. /** Hable */
  66886. Hable = 0,
  66887. /** Reinhard */
  66888. Reinhard = 1,
  66889. /** HejiDawson */
  66890. HejiDawson = 2,
  66891. /** Photographic */
  66892. Photographic = 3
  66893. }
  66894. /**
  66895. * Defines a post process to apply tone mapping
  66896. */
  66897. export class TonemapPostProcess extends PostProcess {
  66898. private _operator;
  66899. /** Defines the required exposure adjustement */
  66900. exposureAdjustment: number;
  66901. /**
  66902. * Creates a new TonemapPostProcess
  66903. * @param name defines the name of the postprocess
  66904. * @param _operator defines the operator to use
  66905. * @param exposureAdjustment defines the required exposure adjustement
  66906. * @param camera defines the camera to use (can be null)
  66907. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66908. * @param engine defines the hosting engine (can be ignore if camera is set)
  66909. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66910. */
  66911. constructor(name: string, _operator: TonemappingOperator,
  66912. /** Defines the required exposure adjustement */
  66913. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66914. }
  66915. }
  66916. declare module BABYLON {
  66917. /** @hidden */
  66918. export var volumetricLightScatteringPixelShader: {
  66919. name: string;
  66920. shader: string;
  66921. };
  66922. }
  66923. declare module BABYLON {
  66924. /** @hidden */
  66925. export var volumetricLightScatteringPassVertexShader: {
  66926. name: string;
  66927. shader: string;
  66928. };
  66929. }
  66930. declare module BABYLON {
  66931. /** @hidden */
  66932. export var volumetricLightScatteringPassPixelShader: {
  66933. name: string;
  66934. shader: string;
  66935. };
  66936. }
  66937. declare module BABYLON {
  66938. /**
  66939. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66940. */
  66941. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66942. private _volumetricLightScatteringPass;
  66943. private _volumetricLightScatteringRTT;
  66944. private _viewPort;
  66945. private _screenCoordinates;
  66946. private _cachedDefines;
  66947. /**
  66948. * If not undefined, the mesh position is computed from the attached node position
  66949. */
  66950. attachedNode: {
  66951. position: Vector3;
  66952. };
  66953. /**
  66954. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66955. */
  66956. customMeshPosition: Vector3;
  66957. /**
  66958. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66959. */
  66960. useCustomMeshPosition: boolean;
  66961. /**
  66962. * If the post-process should inverse the light scattering direction
  66963. */
  66964. invert: boolean;
  66965. /**
  66966. * The internal mesh used by the post-process
  66967. */
  66968. mesh: Mesh;
  66969. /**
  66970. * @hidden
  66971. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66972. */
  66973. get useDiffuseColor(): boolean;
  66974. set useDiffuseColor(useDiffuseColor: boolean);
  66975. /**
  66976. * Array containing the excluded meshes not rendered in the internal pass
  66977. */
  66978. excludedMeshes: AbstractMesh[];
  66979. /**
  66980. * Controls the overall intensity of the post-process
  66981. */
  66982. exposure: number;
  66983. /**
  66984. * Dissipates each sample's contribution in range [0, 1]
  66985. */
  66986. decay: number;
  66987. /**
  66988. * Controls the overall intensity of each sample
  66989. */
  66990. weight: number;
  66991. /**
  66992. * Controls the density of each sample
  66993. */
  66994. density: number;
  66995. /**
  66996. * @constructor
  66997. * @param name The post-process name
  66998. * @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)
  66999. * @param camera The camera that the post-process will be attached to
  67000. * @param mesh The mesh used to create the light scattering
  67001. * @param samples The post-process quality, default 100
  67002. * @param samplingModeThe post-process filtering mode
  67003. * @param engine The babylon engine
  67004. * @param reusable If the post-process is reusable
  67005. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67006. */
  67007. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67008. /**
  67009. * Returns the string "VolumetricLightScatteringPostProcess"
  67010. * @returns "VolumetricLightScatteringPostProcess"
  67011. */
  67012. getClassName(): string;
  67013. private _isReady;
  67014. /**
  67015. * Sets the new light position for light scattering effect
  67016. * @param position The new custom light position
  67017. */
  67018. setCustomMeshPosition(position: Vector3): void;
  67019. /**
  67020. * Returns the light position for light scattering effect
  67021. * @return Vector3 The custom light position
  67022. */
  67023. getCustomMeshPosition(): Vector3;
  67024. /**
  67025. * Disposes the internal assets and detaches the post-process from the camera
  67026. */
  67027. dispose(camera: Camera): void;
  67028. /**
  67029. * Returns the render target texture used by the post-process
  67030. * @return the render target texture used by the post-process
  67031. */
  67032. getPass(): RenderTargetTexture;
  67033. private _meshExcluded;
  67034. private _createPass;
  67035. private _updateMeshScreenCoordinates;
  67036. /**
  67037. * Creates a default mesh for the Volumeric Light Scattering post-process
  67038. * @param name The mesh name
  67039. * @param scene The scene where to create the mesh
  67040. * @return the default mesh
  67041. */
  67042. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67043. }
  67044. }
  67045. declare module BABYLON {
  67046. interface Scene {
  67047. /** @hidden (Backing field) */
  67048. _boundingBoxRenderer: BoundingBoxRenderer;
  67049. /** @hidden (Backing field) */
  67050. _forceShowBoundingBoxes: boolean;
  67051. /**
  67052. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67053. */
  67054. forceShowBoundingBoxes: boolean;
  67055. /**
  67056. * Gets the bounding box renderer associated with the scene
  67057. * @returns a BoundingBoxRenderer
  67058. */
  67059. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67060. }
  67061. interface AbstractMesh {
  67062. /** @hidden (Backing field) */
  67063. _showBoundingBox: boolean;
  67064. /**
  67065. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67066. */
  67067. showBoundingBox: boolean;
  67068. }
  67069. /**
  67070. * Component responsible of rendering the bounding box of the meshes in a scene.
  67071. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67072. */
  67073. export class BoundingBoxRenderer implements ISceneComponent {
  67074. /**
  67075. * The component name helpfull to identify the component in the list of scene components.
  67076. */
  67077. readonly name: string;
  67078. /**
  67079. * The scene the component belongs to.
  67080. */
  67081. scene: Scene;
  67082. /**
  67083. * Color of the bounding box lines placed in front of an object
  67084. */
  67085. frontColor: Color3;
  67086. /**
  67087. * Color of the bounding box lines placed behind an object
  67088. */
  67089. backColor: Color3;
  67090. /**
  67091. * Defines if the renderer should show the back lines or not
  67092. */
  67093. showBackLines: boolean;
  67094. /**
  67095. * @hidden
  67096. */
  67097. renderList: SmartArray<BoundingBox>;
  67098. private _colorShader;
  67099. private _vertexBuffers;
  67100. private _indexBuffer;
  67101. private _fillIndexBuffer;
  67102. private _fillIndexData;
  67103. /**
  67104. * Instantiates a new bounding box renderer in a scene.
  67105. * @param scene the scene the renderer renders in
  67106. */
  67107. constructor(scene: Scene);
  67108. /**
  67109. * Registers the component in a given scene
  67110. */
  67111. register(): void;
  67112. private _evaluateSubMesh;
  67113. private _activeMesh;
  67114. private _prepareRessources;
  67115. private _createIndexBuffer;
  67116. /**
  67117. * Rebuilds the elements related to this component in case of
  67118. * context lost for instance.
  67119. */
  67120. rebuild(): void;
  67121. /**
  67122. * @hidden
  67123. */
  67124. reset(): void;
  67125. /**
  67126. * Render the bounding boxes of a specific rendering group
  67127. * @param renderingGroupId defines the rendering group to render
  67128. */
  67129. render(renderingGroupId: number): void;
  67130. /**
  67131. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67132. * @param mesh Define the mesh to render the occlusion bounding box for
  67133. */
  67134. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67135. /**
  67136. * Dispose and release the resources attached to this renderer.
  67137. */
  67138. dispose(): void;
  67139. }
  67140. }
  67141. declare module BABYLON {
  67142. interface Scene {
  67143. /** @hidden (Backing field) */
  67144. _depthRenderer: {
  67145. [id: string]: DepthRenderer;
  67146. };
  67147. /**
  67148. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67149. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67150. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67151. * @returns the created depth renderer
  67152. */
  67153. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67154. /**
  67155. * Disables a depth renderer for a given camera
  67156. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67157. */
  67158. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67159. }
  67160. /**
  67161. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67162. * in several rendering techniques.
  67163. */
  67164. export class DepthRendererSceneComponent implements ISceneComponent {
  67165. /**
  67166. * The component name helpfull to identify the component in the list of scene components.
  67167. */
  67168. readonly name: string;
  67169. /**
  67170. * The scene the component belongs to.
  67171. */
  67172. scene: Scene;
  67173. /**
  67174. * Creates a new instance of the component for the given scene
  67175. * @param scene Defines the scene to register the component in
  67176. */
  67177. constructor(scene: Scene);
  67178. /**
  67179. * Registers the component in a given scene
  67180. */
  67181. register(): void;
  67182. /**
  67183. * Rebuilds the elements related to this component in case of
  67184. * context lost for instance.
  67185. */
  67186. rebuild(): void;
  67187. /**
  67188. * Disposes the component and the associated ressources
  67189. */
  67190. dispose(): void;
  67191. private _gatherRenderTargets;
  67192. private _gatherActiveCameraRenderTargets;
  67193. }
  67194. }
  67195. declare module BABYLON {
  67196. /** @hidden */
  67197. export var outlinePixelShader: {
  67198. name: string;
  67199. shader: string;
  67200. };
  67201. }
  67202. declare module BABYLON {
  67203. /** @hidden */
  67204. export var outlineVertexShader: {
  67205. name: string;
  67206. shader: string;
  67207. };
  67208. }
  67209. declare module BABYLON {
  67210. interface Scene {
  67211. /** @hidden */
  67212. _outlineRenderer: OutlineRenderer;
  67213. /**
  67214. * Gets the outline renderer associated with the scene
  67215. * @returns a OutlineRenderer
  67216. */
  67217. getOutlineRenderer(): OutlineRenderer;
  67218. }
  67219. interface AbstractMesh {
  67220. /** @hidden (Backing field) */
  67221. _renderOutline: boolean;
  67222. /**
  67223. * Gets or sets a boolean indicating if the outline must be rendered as well
  67224. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67225. */
  67226. renderOutline: boolean;
  67227. /** @hidden (Backing field) */
  67228. _renderOverlay: boolean;
  67229. /**
  67230. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67231. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67232. */
  67233. renderOverlay: boolean;
  67234. }
  67235. /**
  67236. * This class is responsible to draw bothe outline/overlay of meshes.
  67237. * It should not be used directly but through the available method on mesh.
  67238. */
  67239. export class OutlineRenderer implements ISceneComponent {
  67240. /**
  67241. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67242. */
  67243. private static _StencilReference;
  67244. /**
  67245. * The name of the component. Each component must have a unique name.
  67246. */
  67247. name: string;
  67248. /**
  67249. * The scene the component belongs to.
  67250. */
  67251. scene: Scene;
  67252. /**
  67253. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67254. */
  67255. zOffset: number;
  67256. private _engine;
  67257. private _effect;
  67258. private _cachedDefines;
  67259. private _savedDepthWrite;
  67260. /**
  67261. * Instantiates a new outline renderer. (There could be only one per scene).
  67262. * @param scene Defines the scene it belongs to
  67263. */
  67264. constructor(scene: Scene);
  67265. /**
  67266. * Register the component to one instance of a scene.
  67267. */
  67268. register(): void;
  67269. /**
  67270. * Rebuilds the elements related to this component in case of
  67271. * context lost for instance.
  67272. */
  67273. rebuild(): void;
  67274. /**
  67275. * Disposes the component and the associated ressources.
  67276. */
  67277. dispose(): void;
  67278. /**
  67279. * Renders the outline in the canvas.
  67280. * @param subMesh Defines the sumesh to render
  67281. * @param batch Defines the batch of meshes in case of instances
  67282. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67283. */
  67284. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67285. /**
  67286. * Returns whether or not the outline renderer is ready for a given submesh.
  67287. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67288. * @param subMesh Defines the submesh to check readyness for
  67289. * @param useInstances Defines wheter wee are trying to render instances or not
  67290. * @returns true if ready otherwise false
  67291. */
  67292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67293. private _beforeRenderingMesh;
  67294. private _afterRenderingMesh;
  67295. }
  67296. }
  67297. declare module BABYLON {
  67298. /**
  67299. * Defines the basic options interface of a Sprite Frame Source Size.
  67300. */
  67301. export interface ISpriteJSONSpriteSourceSize {
  67302. /**
  67303. * number of the original width of the Frame
  67304. */
  67305. w: number;
  67306. /**
  67307. * number of the original height of the Frame
  67308. */
  67309. h: number;
  67310. }
  67311. /**
  67312. * Defines the basic options interface of a Sprite Frame Data.
  67313. */
  67314. export interface ISpriteJSONSpriteFrameData {
  67315. /**
  67316. * number of the x offset of the Frame
  67317. */
  67318. x: number;
  67319. /**
  67320. * number of the y offset of the Frame
  67321. */
  67322. y: number;
  67323. /**
  67324. * number of the width of the Frame
  67325. */
  67326. w: number;
  67327. /**
  67328. * number of the height of the Frame
  67329. */
  67330. h: number;
  67331. }
  67332. /**
  67333. * Defines the basic options interface of a JSON Sprite.
  67334. */
  67335. export interface ISpriteJSONSprite {
  67336. /**
  67337. * string name of the Frame
  67338. */
  67339. filename: string;
  67340. /**
  67341. * ISpriteJSONSpriteFrame basic object of the frame data
  67342. */
  67343. frame: ISpriteJSONSpriteFrameData;
  67344. /**
  67345. * boolean to flag is the frame was rotated.
  67346. */
  67347. rotated: boolean;
  67348. /**
  67349. * boolean to flag is the frame was trimmed.
  67350. */
  67351. trimmed: boolean;
  67352. /**
  67353. * ISpriteJSONSpriteFrame basic object of the source data
  67354. */
  67355. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67356. /**
  67357. * ISpriteJSONSpriteFrame basic object of the source data
  67358. */
  67359. sourceSize: ISpriteJSONSpriteSourceSize;
  67360. }
  67361. /**
  67362. * Defines the basic options interface of a JSON atlas.
  67363. */
  67364. export interface ISpriteJSONAtlas {
  67365. /**
  67366. * Array of objects that contain the frame data.
  67367. */
  67368. frames: Array<ISpriteJSONSprite>;
  67369. /**
  67370. * object basic object containing the sprite meta data.
  67371. */
  67372. meta?: object;
  67373. }
  67374. }
  67375. declare module BABYLON {
  67376. /** @hidden */
  67377. export var spriteMapPixelShader: {
  67378. name: string;
  67379. shader: string;
  67380. };
  67381. }
  67382. declare module BABYLON {
  67383. /** @hidden */
  67384. export var spriteMapVertexShader: {
  67385. name: string;
  67386. shader: string;
  67387. };
  67388. }
  67389. declare module BABYLON {
  67390. /**
  67391. * Defines the basic options interface of a SpriteMap
  67392. */
  67393. export interface ISpriteMapOptions {
  67394. /**
  67395. * Vector2 of the number of cells in the grid.
  67396. */
  67397. stageSize?: Vector2;
  67398. /**
  67399. * Vector2 of the size of the output plane in World Units.
  67400. */
  67401. outputSize?: Vector2;
  67402. /**
  67403. * Vector3 of the position of the output plane in World Units.
  67404. */
  67405. outputPosition?: Vector3;
  67406. /**
  67407. * Vector3 of the rotation of the output plane.
  67408. */
  67409. outputRotation?: Vector3;
  67410. /**
  67411. * number of layers that the system will reserve in resources.
  67412. */
  67413. layerCount?: number;
  67414. /**
  67415. * number of max animation frames a single cell will reserve in resources.
  67416. */
  67417. maxAnimationFrames?: number;
  67418. /**
  67419. * number cell index of the base tile when the system compiles.
  67420. */
  67421. baseTile?: number;
  67422. /**
  67423. * boolean flip the sprite after its been repositioned by the framing data.
  67424. */
  67425. flipU?: boolean;
  67426. /**
  67427. * Vector3 scalar of the global RGB values of the SpriteMap.
  67428. */
  67429. colorMultiply?: Vector3;
  67430. }
  67431. /**
  67432. * Defines the IDisposable interface in order to be cleanable from resources.
  67433. */
  67434. export interface ISpriteMap extends IDisposable {
  67435. /**
  67436. * String name of the SpriteMap.
  67437. */
  67438. name: string;
  67439. /**
  67440. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67441. */
  67442. atlasJSON: ISpriteJSONAtlas;
  67443. /**
  67444. * Texture of the SpriteMap.
  67445. */
  67446. spriteSheet: Texture;
  67447. /**
  67448. * The parameters to initialize the SpriteMap with.
  67449. */
  67450. options: ISpriteMapOptions;
  67451. }
  67452. /**
  67453. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67454. */
  67455. export class SpriteMap implements ISpriteMap {
  67456. /** The Name of the spriteMap */
  67457. name: string;
  67458. /** The JSON file with the frame and meta data */
  67459. atlasJSON: ISpriteJSONAtlas;
  67460. /** The systems Sprite Sheet Texture */
  67461. spriteSheet: Texture;
  67462. /** Arguments passed with the Constructor */
  67463. options: ISpriteMapOptions;
  67464. /** Public Sprite Storage array, parsed from atlasJSON */
  67465. sprites: Array<ISpriteJSONSprite>;
  67466. /** Returns the Number of Sprites in the System */
  67467. get spriteCount(): number;
  67468. /** Returns the Position of Output Plane*/
  67469. get position(): Vector3;
  67470. /** Returns the Position of Output Plane*/
  67471. set position(v: Vector3);
  67472. /** Returns the Rotation of Output Plane*/
  67473. get rotation(): Vector3;
  67474. /** Returns the Rotation of Output Plane*/
  67475. set rotation(v: Vector3);
  67476. /** Sets the AnimationMap*/
  67477. get animationMap(): RawTexture;
  67478. /** Sets the AnimationMap*/
  67479. set animationMap(v: RawTexture);
  67480. /** Scene that the SpriteMap was created in */
  67481. private _scene;
  67482. /** Texture Buffer of Float32 that holds tile frame data*/
  67483. private _frameMap;
  67484. /** Texture Buffers of Float32 that holds tileMap data*/
  67485. private _tileMaps;
  67486. /** Texture Buffer of Float32 that holds Animation Data*/
  67487. private _animationMap;
  67488. /** Custom ShaderMaterial Central to the System*/
  67489. private _material;
  67490. /** Custom ShaderMaterial Central to the System*/
  67491. private _output;
  67492. /** Systems Time Ticker*/
  67493. private _time;
  67494. /**
  67495. * Creates a new SpriteMap
  67496. * @param name defines the SpriteMaps Name
  67497. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67498. * @param spriteSheet is the Texture that the Sprites are on.
  67499. * @param options a basic deployment configuration
  67500. * @param scene The Scene that the map is deployed on
  67501. */
  67502. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67503. /**
  67504. * Returns tileID location
  67505. * @returns Vector2 the cell position ID
  67506. */
  67507. getTileID(): Vector2;
  67508. /**
  67509. * Gets the UV location of the mouse over the SpriteMap.
  67510. * @returns Vector2 the UV position of the mouse interaction
  67511. */
  67512. getMousePosition(): Vector2;
  67513. /**
  67514. * Creates the "frame" texture Buffer
  67515. * -------------------------------------
  67516. * Structure of frames
  67517. * "filename": "Falling-Water-2.png",
  67518. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67519. * "rotated": true,
  67520. * "trimmed": true,
  67521. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67522. * "sourceSize": {"w":32,"h":32}
  67523. * @returns RawTexture of the frameMap
  67524. */
  67525. private _createFrameBuffer;
  67526. /**
  67527. * Creates the tileMap texture Buffer
  67528. * @param buffer normally and array of numbers, or a false to generate from scratch
  67529. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67530. * @returns RawTexture of the tileMap
  67531. */
  67532. private _createTileBuffer;
  67533. /**
  67534. * Modifies the data of the tileMaps
  67535. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67536. * @param pos is the iVector2 Coordinates of the Tile
  67537. * @param tile The SpriteIndex of the new Tile
  67538. */
  67539. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67540. /**
  67541. * Creates the animationMap texture Buffer
  67542. * @param buffer normally and array of numbers, or a false to generate from scratch
  67543. * @returns RawTexture of the animationMap
  67544. */
  67545. private _createTileAnimationBuffer;
  67546. /**
  67547. * Modifies the data of the animationMap
  67548. * @param cellID is the Index of the Sprite
  67549. * @param _frame is the target Animation frame
  67550. * @param toCell is the Target Index of the next frame of the animation
  67551. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67552. * @param speed is a global scalar of the time variable on the map.
  67553. */
  67554. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67555. /**
  67556. * Exports the .tilemaps file
  67557. */
  67558. saveTileMaps(): void;
  67559. /**
  67560. * Imports the .tilemaps file
  67561. * @param url of the .tilemaps file
  67562. */
  67563. loadTileMaps(url: string): void;
  67564. /**
  67565. * Release associated resources
  67566. */
  67567. dispose(): void;
  67568. }
  67569. }
  67570. declare module BABYLON {
  67571. /**
  67572. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67573. * @see http://doc.babylonjs.com/babylon101/sprites
  67574. */
  67575. export class SpritePackedManager extends SpriteManager {
  67576. /** defines the packed manager's name */
  67577. name: string;
  67578. /**
  67579. * Creates a new sprite manager from a packed sprite sheet
  67580. * @param name defines the manager's name
  67581. * @param imgUrl defines the sprite sheet url
  67582. * @param capacity defines the maximum allowed number of sprites
  67583. * @param scene defines the hosting scene
  67584. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67585. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67586. * @param samplingMode defines the smapling mode to use with spritesheet
  67587. * @param fromPacked set to true; do not alter
  67588. */
  67589. constructor(
  67590. /** defines the packed manager's name */
  67591. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67592. }
  67593. }
  67594. declare module BABYLON {
  67595. /**
  67596. * Defines the list of states available for a task inside a AssetsManager
  67597. */
  67598. export enum AssetTaskState {
  67599. /**
  67600. * Initialization
  67601. */
  67602. INIT = 0,
  67603. /**
  67604. * Running
  67605. */
  67606. RUNNING = 1,
  67607. /**
  67608. * Done
  67609. */
  67610. DONE = 2,
  67611. /**
  67612. * Error
  67613. */
  67614. ERROR = 3
  67615. }
  67616. /**
  67617. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67618. */
  67619. export abstract class AbstractAssetTask {
  67620. /**
  67621. * Task name
  67622. */ name: string;
  67623. /**
  67624. * Callback called when the task is successful
  67625. */
  67626. onSuccess: (task: any) => void;
  67627. /**
  67628. * Callback called when the task is not successful
  67629. */
  67630. onError: (task: any, message?: string, exception?: any) => void;
  67631. /**
  67632. * Creates a new AssetsManager
  67633. * @param name defines the name of the task
  67634. */
  67635. constructor(
  67636. /**
  67637. * Task name
  67638. */ name: string);
  67639. private _isCompleted;
  67640. private _taskState;
  67641. private _errorObject;
  67642. /**
  67643. * Get if the task is completed
  67644. */
  67645. get isCompleted(): boolean;
  67646. /**
  67647. * Gets the current state of the task
  67648. */
  67649. get taskState(): AssetTaskState;
  67650. /**
  67651. * Gets the current error object (if task is in error)
  67652. */
  67653. get errorObject(): {
  67654. message?: string;
  67655. exception?: any;
  67656. };
  67657. /**
  67658. * Internal only
  67659. * @hidden
  67660. */
  67661. _setErrorObject(message?: string, exception?: any): void;
  67662. /**
  67663. * Execute the current task
  67664. * @param scene defines the scene where you want your assets to be loaded
  67665. * @param onSuccess is a callback called when the task is successfully executed
  67666. * @param onError is a callback called if an error occurs
  67667. */
  67668. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67669. /**
  67670. * Execute the current task
  67671. * @param scene defines the scene where you want your assets to be loaded
  67672. * @param onSuccess is a callback called when the task is successfully executed
  67673. * @param onError is a callback called if an error occurs
  67674. */
  67675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67676. /**
  67677. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67678. * This can be used with failed tasks that have the reason for failure fixed.
  67679. */
  67680. reset(): void;
  67681. private onErrorCallback;
  67682. private onDoneCallback;
  67683. }
  67684. /**
  67685. * Define the interface used by progress events raised during assets loading
  67686. */
  67687. export interface IAssetsProgressEvent {
  67688. /**
  67689. * Defines the number of remaining tasks to process
  67690. */
  67691. remainingCount: number;
  67692. /**
  67693. * Defines the total number of tasks
  67694. */
  67695. totalCount: number;
  67696. /**
  67697. * Defines the task that was just processed
  67698. */
  67699. task: AbstractAssetTask;
  67700. }
  67701. /**
  67702. * Class used to share progress information about assets loading
  67703. */
  67704. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67705. /**
  67706. * Defines the number of remaining tasks to process
  67707. */
  67708. remainingCount: number;
  67709. /**
  67710. * Defines the total number of tasks
  67711. */
  67712. totalCount: number;
  67713. /**
  67714. * Defines the task that was just processed
  67715. */
  67716. task: AbstractAssetTask;
  67717. /**
  67718. * Creates a AssetsProgressEvent
  67719. * @param remainingCount defines the number of remaining tasks to process
  67720. * @param totalCount defines the total number of tasks
  67721. * @param task defines the task that was just processed
  67722. */
  67723. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67724. }
  67725. /**
  67726. * Define a task used by AssetsManager to load meshes
  67727. */
  67728. export class MeshAssetTask extends AbstractAssetTask {
  67729. /**
  67730. * Defines the name of the task
  67731. */
  67732. name: string;
  67733. /**
  67734. * Defines the list of mesh's names you want to load
  67735. */
  67736. meshesNames: any;
  67737. /**
  67738. * Defines the root url to use as a base to load your meshes and associated resources
  67739. */
  67740. rootUrl: string;
  67741. /**
  67742. * Defines the filename of the scene to load from
  67743. */
  67744. sceneFilename: string;
  67745. /**
  67746. * Gets the list of loaded meshes
  67747. */
  67748. loadedMeshes: Array<AbstractMesh>;
  67749. /**
  67750. * Gets the list of loaded particle systems
  67751. */
  67752. loadedParticleSystems: Array<IParticleSystem>;
  67753. /**
  67754. * Gets the list of loaded skeletons
  67755. */
  67756. loadedSkeletons: Array<Skeleton>;
  67757. /**
  67758. * Gets the list of loaded animation groups
  67759. */
  67760. loadedAnimationGroups: Array<AnimationGroup>;
  67761. /**
  67762. * Callback called when the task is successful
  67763. */
  67764. onSuccess: (task: MeshAssetTask) => void;
  67765. /**
  67766. * Callback called when the task is successful
  67767. */
  67768. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67769. /**
  67770. * Creates a new MeshAssetTask
  67771. * @param name defines the name of the task
  67772. * @param meshesNames defines the list of mesh's names you want to load
  67773. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67774. * @param sceneFilename defines the filename of the scene to load from
  67775. */
  67776. constructor(
  67777. /**
  67778. * Defines the name of the task
  67779. */
  67780. name: string,
  67781. /**
  67782. * Defines the list of mesh's names you want to load
  67783. */
  67784. meshesNames: any,
  67785. /**
  67786. * Defines the root url to use as a base to load your meshes and associated resources
  67787. */
  67788. rootUrl: string,
  67789. /**
  67790. * Defines the filename of the scene to load from
  67791. */
  67792. sceneFilename: string);
  67793. /**
  67794. * Execute the current task
  67795. * @param scene defines the scene where you want your assets to be loaded
  67796. * @param onSuccess is a callback called when the task is successfully executed
  67797. * @param onError is a callback called if an error occurs
  67798. */
  67799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67800. }
  67801. /**
  67802. * Define a task used by AssetsManager to load text content
  67803. */
  67804. export class TextFileAssetTask extends AbstractAssetTask {
  67805. /**
  67806. * Defines the name of the task
  67807. */
  67808. name: string;
  67809. /**
  67810. * Defines the location of the file to load
  67811. */
  67812. url: string;
  67813. /**
  67814. * Gets the loaded text string
  67815. */
  67816. text: string;
  67817. /**
  67818. * Callback called when the task is successful
  67819. */
  67820. onSuccess: (task: TextFileAssetTask) => void;
  67821. /**
  67822. * Callback called when the task is successful
  67823. */
  67824. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67825. /**
  67826. * Creates a new TextFileAssetTask object
  67827. * @param name defines the name of the task
  67828. * @param url defines the location of the file to load
  67829. */
  67830. constructor(
  67831. /**
  67832. * Defines the name of the task
  67833. */
  67834. name: string,
  67835. /**
  67836. * Defines the location of the file to load
  67837. */
  67838. url: string);
  67839. /**
  67840. * Execute the current task
  67841. * @param scene defines the scene where you want your assets to be loaded
  67842. * @param onSuccess is a callback called when the task is successfully executed
  67843. * @param onError is a callback called if an error occurs
  67844. */
  67845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67846. }
  67847. /**
  67848. * Define a task used by AssetsManager to load binary data
  67849. */
  67850. export class BinaryFileAssetTask extends AbstractAssetTask {
  67851. /**
  67852. * Defines the name of the task
  67853. */
  67854. name: string;
  67855. /**
  67856. * Defines the location of the file to load
  67857. */
  67858. url: string;
  67859. /**
  67860. * Gets the lodaded data (as an array buffer)
  67861. */
  67862. data: ArrayBuffer;
  67863. /**
  67864. * Callback called when the task is successful
  67865. */
  67866. onSuccess: (task: BinaryFileAssetTask) => void;
  67867. /**
  67868. * Callback called when the task is successful
  67869. */
  67870. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67871. /**
  67872. * Creates a new BinaryFileAssetTask object
  67873. * @param name defines the name of the new task
  67874. * @param url defines the location of the file to load
  67875. */
  67876. constructor(
  67877. /**
  67878. * Defines the name of the task
  67879. */
  67880. name: string,
  67881. /**
  67882. * Defines the location of the file to load
  67883. */
  67884. url: string);
  67885. /**
  67886. * Execute the current task
  67887. * @param scene defines the scene where you want your assets to be loaded
  67888. * @param onSuccess is a callback called when the task is successfully executed
  67889. * @param onError is a callback called if an error occurs
  67890. */
  67891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67892. }
  67893. /**
  67894. * Define a task used by AssetsManager to load images
  67895. */
  67896. export class ImageAssetTask extends AbstractAssetTask {
  67897. /**
  67898. * Defines the name of the task
  67899. */
  67900. name: string;
  67901. /**
  67902. * Defines the location of the image to load
  67903. */
  67904. url: string;
  67905. /**
  67906. * Gets the loaded images
  67907. */
  67908. image: HTMLImageElement;
  67909. /**
  67910. * Callback called when the task is successful
  67911. */
  67912. onSuccess: (task: ImageAssetTask) => void;
  67913. /**
  67914. * Callback called when the task is successful
  67915. */
  67916. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67917. /**
  67918. * Creates a new ImageAssetTask
  67919. * @param name defines the name of the task
  67920. * @param url defines the location of the image to load
  67921. */
  67922. constructor(
  67923. /**
  67924. * Defines the name of the task
  67925. */
  67926. name: string,
  67927. /**
  67928. * Defines the location of the image to load
  67929. */
  67930. url: string);
  67931. /**
  67932. * Execute the current task
  67933. * @param scene defines the scene where you want your assets to be loaded
  67934. * @param onSuccess is a callback called when the task is successfully executed
  67935. * @param onError is a callback called if an error occurs
  67936. */
  67937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67938. }
  67939. /**
  67940. * Defines the interface used by texture loading tasks
  67941. */
  67942. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67943. /**
  67944. * Gets the loaded texture
  67945. */
  67946. texture: TEX;
  67947. }
  67948. /**
  67949. * Define a task used by AssetsManager to load 2D textures
  67950. */
  67951. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67952. /**
  67953. * Defines the name of the task
  67954. */
  67955. name: string;
  67956. /**
  67957. * Defines the location of the file to load
  67958. */
  67959. url: string;
  67960. /**
  67961. * Defines if mipmap should not be generated (default is false)
  67962. */
  67963. noMipmap?: boolean | undefined;
  67964. /**
  67965. * Defines if texture must be inverted on Y axis (default is false)
  67966. */
  67967. invertY?: boolean | undefined;
  67968. /**
  67969. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67970. */
  67971. samplingMode: number;
  67972. /**
  67973. * Gets the loaded texture
  67974. */
  67975. texture: Texture;
  67976. /**
  67977. * Callback called when the task is successful
  67978. */
  67979. onSuccess: (task: TextureAssetTask) => void;
  67980. /**
  67981. * Callback called when the task is successful
  67982. */
  67983. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67984. /**
  67985. * Creates a new TextureAssetTask object
  67986. * @param name defines the name of the task
  67987. * @param url defines the location of the file to load
  67988. * @param noMipmap defines if mipmap should not be generated (default is false)
  67989. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67990. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67991. */
  67992. constructor(
  67993. /**
  67994. * Defines the name of the task
  67995. */
  67996. name: string,
  67997. /**
  67998. * Defines the location of the file to load
  67999. */
  68000. url: string,
  68001. /**
  68002. * Defines if mipmap should not be generated (default is false)
  68003. */
  68004. noMipmap?: boolean | undefined,
  68005. /**
  68006. * Defines if texture must be inverted on Y axis (default is false)
  68007. */
  68008. invertY?: boolean | undefined,
  68009. /**
  68010. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68011. */
  68012. samplingMode?: number);
  68013. /**
  68014. * Execute the current task
  68015. * @param scene defines the scene where you want your assets to be loaded
  68016. * @param onSuccess is a callback called when the task is successfully executed
  68017. * @param onError is a callback called if an error occurs
  68018. */
  68019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68020. }
  68021. /**
  68022. * Define a task used by AssetsManager to load cube textures
  68023. */
  68024. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68025. /**
  68026. * Defines the name of the task
  68027. */
  68028. name: string;
  68029. /**
  68030. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68031. */
  68032. url: string;
  68033. /**
  68034. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68035. */
  68036. extensions?: string[] | undefined;
  68037. /**
  68038. * Defines if mipmaps should not be generated (default is false)
  68039. */
  68040. noMipmap?: boolean | undefined;
  68041. /**
  68042. * Defines the explicit list of files (undefined by default)
  68043. */
  68044. files?: string[] | undefined;
  68045. /**
  68046. * Gets the loaded texture
  68047. */
  68048. texture: CubeTexture;
  68049. /**
  68050. * Callback called when the task is successful
  68051. */
  68052. onSuccess: (task: CubeTextureAssetTask) => void;
  68053. /**
  68054. * Callback called when the task is successful
  68055. */
  68056. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68057. /**
  68058. * Creates a new CubeTextureAssetTask
  68059. * @param name defines the name of the task
  68060. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68061. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68062. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68063. * @param files defines the explicit list of files (undefined by default)
  68064. */
  68065. constructor(
  68066. /**
  68067. * Defines the name of the task
  68068. */
  68069. name: string,
  68070. /**
  68071. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68072. */
  68073. url: string,
  68074. /**
  68075. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68076. */
  68077. extensions?: string[] | undefined,
  68078. /**
  68079. * Defines if mipmaps should not be generated (default is false)
  68080. */
  68081. noMipmap?: boolean | undefined,
  68082. /**
  68083. * Defines the explicit list of files (undefined by default)
  68084. */
  68085. files?: string[] | undefined);
  68086. /**
  68087. * Execute the current task
  68088. * @param scene defines the scene where you want your assets to be loaded
  68089. * @param onSuccess is a callback called when the task is successfully executed
  68090. * @param onError is a callback called if an error occurs
  68091. */
  68092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68093. }
  68094. /**
  68095. * Define a task used by AssetsManager to load HDR cube textures
  68096. */
  68097. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68098. /**
  68099. * Defines the name of the task
  68100. */
  68101. name: string;
  68102. /**
  68103. * Defines the location of the file to load
  68104. */
  68105. url: string;
  68106. /**
  68107. * Defines the desired size (the more it increases the longer the generation will be)
  68108. */
  68109. size: number;
  68110. /**
  68111. * Defines if mipmaps should not be generated (default is false)
  68112. */
  68113. noMipmap: boolean;
  68114. /**
  68115. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68116. */
  68117. generateHarmonics: boolean;
  68118. /**
  68119. * 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)
  68120. */
  68121. gammaSpace: boolean;
  68122. /**
  68123. * Internal Use Only
  68124. */
  68125. reserved: boolean;
  68126. /**
  68127. * Gets the loaded texture
  68128. */
  68129. texture: HDRCubeTexture;
  68130. /**
  68131. * Callback called when the task is successful
  68132. */
  68133. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68134. /**
  68135. * Callback called when the task is successful
  68136. */
  68137. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68138. /**
  68139. * Creates a new HDRCubeTextureAssetTask object
  68140. * @param name defines the name of the task
  68141. * @param url defines the location of the file to load
  68142. * @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.
  68143. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68144. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68145. * @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)
  68146. * @param reserved Internal use only
  68147. */
  68148. constructor(
  68149. /**
  68150. * Defines the name of the task
  68151. */
  68152. name: string,
  68153. /**
  68154. * Defines the location of the file to load
  68155. */
  68156. url: string,
  68157. /**
  68158. * Defines the desired size (the more it increases the longer the generation will be)
  68159. */
  68160. size: number,
  68161. /**
  68162. * Defines if mipmaps should not be generated (default is false)
  68163. */
  68164. noMipmap?: boolean,
  68165. /**
  68166. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68167. */
  68168. generateHarmonics?: boolean,
  68169. /**
  68170. * 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)
  68171. */
  68172. gammaSpace?: boolean,
  68173. /**
  68174. * Internal Use Only
  68175. */
  68176. reserved?: boolean);
  68177. /**
  68178. * Execute the current task
  68179. * @param scene defines the scene where you want your assets to be loaded
  68180. * @param onSuccess is a callback called when the task is successfully executed
  68181. * @param onError is a callback called if an error occurs
  68182. */
  68183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68184. }
  68185. /**
  68186. * Define a task used by AssetsManager to load Equirectangular cube textures
  68187. */
  68188. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68189. /**
  68190. * Defines the name of the task
  68191. */
  68192. name: string;
  68193. /**
  68194. * Defines the location of the file to load
  68195. */
  68196. url: string;
  68197. /**
  68198. * Defines the desired size (the more it increases the longer the generation will be)
  68199. */
  68200. size: number;
  68201. /**
  68202. * Defines if mipmaps should not be generated (default is false)
  68203. */
  68204. noMipmap: boolean;
  68205. /**
  68206. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68207. * but the standard material would require them in Gamma space) (default is true)
  68208. */
  68209. gammaSpace: boolean;
  68210. /**
  68211. * Gets the loaded texture
  68212. */
  68213. texture: EquiRectangularCubeTexture;
  68214. /**
  68215. * Callback called when the task is successful
  68216. */
  68217. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68218. /**
  68219. * Callback called when the task is successful
  68220. */
  68221. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68222. /**
  68223. * Creates a new EquiRectangularCubeTextureAssetTask object
  68224. * @param name defines the name of the task
  68225. * @param url defines the location of the file to load
  68226. * @param size defines the desired size (the more it increases the longer the generation will be)
  68227. * If the size is omitted this implies you are using a preprocessed cubemap.
  68228. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68229. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68230. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68231. * (default is true)
  68232. */
  68233. constructor(
  68234. /**
  68235. * Defines the name of the task
  68236. */
  68237. name: string,
  68238. /**
  68239. * Defines the location of the file to load
  68240. */
  68241. url: string,
  68242. /**
  68243. * Defines the desired size (the more it increases the longer the generation will be)
  68244. */
  68245. size: number,
  68246. /**
  68247. * Defines if mipmaps should not be generated (default is false)
  68248. */
  68249. noMipmap?: boolean,
  68250. /**
  68251. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68252. * but the standard material would require them in Gamma space) (default is true)
  68253. */
  68254. gammaSpace?: boolean);
  68255. /**
  68256. * Execute the current task
  68257. * @param scene defines the scene where you want your assets to be loaded
  68258. * @param onSuccess is a callback called when the task is successfully executed
  68259. * @param onError is a callback called if an error occurs
  68260. */
  68261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68262. }
  68263. /**
  68264. * This class can be used to easily import assets into a scene
  68265. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68266. */
  68267. export class AssetsManager {
  68268. private _scene;
  68269. private _isLoading;
  68270. protected _tasks: AbstractAssetTask[];
  68271. protected _waitingTasksCount: number;
  68272. protected _totalTasksCount: number;
  68273. /**
  68274. * Callback called when all tasks are processed
  68275. */
  68276. onFinish: (tasks: AbstractAssetTask[]) => void;
  68277. /**
  68278. * Callback called when a task is successful
  68279. */
  68280. onTaskSuccess: (task: AbstractAssetTask) => void;
  68281. /**
  68282. * Callback called when a task had an error
  68283. */
  68284. onTaskError: (task: AbstractAssetTask) => void;
  68285. /**
  68286. * Callback called when a task is done (whatever the result is)
  68287. */
  68288. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68289. /**
  68290. * Observable called when all tasks are processed
  68291. */
  68292. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68293. /**
  68294. * Observable called when a task had an error
  68295. */
  68296. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68297. /**
  68298. * Observable called when all tasks were executed
  68299. */
  68300. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68301. /**
  68302. * Observable called when a task is done (whatever the result is)
  68303. */
  68304. onProgressObservable: Observable<IAssetsProgressEvent>;
  68305. /**
  68306. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68308. */
  68309. useDefaultLoadingScreen: boolean;
  68310. /**
  68311. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68312. * when all assets have been downloaded.
  68313. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68314. */
  68315. autoHideLoadingUI: boolean;
  68316. /**
  68317. * Creates a new AssetsManager
  68318. * @param scene defines the scene to work on
  68319. */
  68320. constructor(scene: Scene);
  68321. /**
  68322. * Add a MeshAssetTask to the list of active tasks
  68323. * @param taskName defines the name of the new task
  68324. * @param meshesNames defines the name of meshes to load
  68325. * @param rootUrl defines the root url to use to locate files
  68326. * @param sceneFilename defines the filename of the scene file
  68327. * @returns a new MeshAssetTask object
  68328. */
  68329. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68330. /**
  68331. * Add a TextFileAssetTask to the list of active tasks
  68332. * @param taskName defines the name of the new task
  68333. * @param url defines the url of the file to load
  68334. * @returns a new TextFileAssetTask object
  68335. */
  68336. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68337. /**
  68338. * Add a BinaryFileAssetTask to the list of active tasks
  68339. * @param taskName defines the name of the new task
  68340. * @param url defines the url of the file to load
  68341. * @returns a new BinaryFileAssetTask object
  68342. */
  68343. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68344. /**
  68345. * Add a ImageAssetTask to the list of active tasks
  68346. * @param taskName defines the name of the new task
  68347. * @param url defines the url of the file to load
  68348. * @returns a new ImageAssetTask object
  68349. */
  68350. addImageTask(taskName: string, url: string): ImageAssetTask;
  68351. /**
  68352. * Add a TextureAssetTask to the list of active tasks
  68353. * @param taskName defines the name of the new task
  68354. * @param url defines the url of the file to load
  68355. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68356. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68357. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68358. * @returns a new TextureAssetTask object
  68359. */
  68360. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68361. /**
  68362. * Add a CubeTextureAssetTask to the list of active tasks
  68363. * @param taskName defines the name of the new task
  68364. * @param url defines the url of the file to load
  68365. * @param extensions defines the extension to use to load the cube map (can be null)
  68366. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68367. * @param files defines the list of files to load (can be null)
  68368. * @returns a new CubeTextureAssetTask object
  68369. */
  68370. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68371. /**
  68372. *
  68373. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68374. * @param taskName defines the name of the new task
  68375. * @param url defines the url of the file to load
  68376. * @param size defines the size you want for the cubemap (can be null)
  68377. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68378. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68379. * @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)
  68380. * @param reserved Internal use only
  68381. * @returns a new HDRCubeTextureAssetTask object
  68382. */
  68383. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68384. /**
  68385. *
  68386. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68387. * @param taskName defines the name of the new task
  68388. * @param url defines the url of the file to load
  68389. * @param size defines the size you want for the cubemap (can be null)
  68390. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68391. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68392. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68393. * @returns a new EquiRectangularCubeTextureAssetTask object
  68394. */
  68395. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68396. /**
  68397. * Remove a task from the assets manager.
  68398. * @param task the task to remove
  68399. */
  68400. removeTask(task: AbstractAssetTask): void;
  68401. private _decreaseWaitingTasksCount;
  68402. private _runTask;
  68403. /**
  68404. * Reset the AssetsManager and remove all tasks
  68405. * @return the current instance of the AssetsManager
  68406. */
  68407. reset(): AssetsManager;
  68408. /**
  68409. * Start the loading process
  68410. * @return the current instance of the AssetsManager
  68411. */
  68412. load(): AssetsManager;
  68413. /**
  68414. * Start the loading process as an async operation
  68415. * @return a promise returning the list of failed tasks
  68416. */
  68417. loadAsync(): Promise<void>;
  68418. }
  68419. }
  68420. declare module BABYLON {
  68421. /**
  68422. * Wrapper class for promise with external resolve and reject.
  68423. */
  68424. export class Deferred<T> {
  68425. /**
  68426. * The promise associated with this deferred object.
  68427. */
  68428. readonly promise: Promise<T>;
  68429. private _resolve;
  68430. private _reject;
  68431. /**
  68432. * The resolve method of the promise associated with this deferred object.
  68433. */
  68434. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68435. /**
  68436. * The reject method of the promise associated with this deferred object.
  68437. */
  68438. get reject(): (reason?: any) => void;
  68439. /**
  68440. * Constructor for this deferred object.
  68441. */
  68442. constructor();
  68443. }
  68444. }
  68445. declare module BABYLON {
  68446. /**
  68447. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68448. */
  68449. export class MeshExploder {
  68450. private _centerMesh;
  68451. private _meshes;
  68452. private _meshesOrigins;
  68453. private _toCenterVectors;
  68454. private _scaledDirection;
  68455. private _newPosition;
  68456. private _centerPosition;
  68457. /**
  68458. * Explodes meshes from a center mesh.
  68459. * @param meshes The meshes to explode.
  68460. * @param centerMesh The mesh to be center of explosion.
  68461. */
  68462. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68463. private _setCenterMesh;
  68464. /**
  68465. * Get class name
  68466. * @returns "MeshExploder"
  68467. */
  68468. getClassName(): string;
  68469. /**
  68470. * "Exploded meshes"
  68471. * @returns Array of meshes with the centerMesh at index 0.
  68472. */
  68473. getMeshes(): Array<Mesh>;
  68474. /**
  68475. * Explodes meshes giving a specific direction
  68476. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68477. */
  68478. explode(direction?: number): void;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /**
  68483. * Class used to help managing file picking and drag'n'drop
  68484. */
  68485. export class FilesInput {
  68486. /**
  68487. * List of files ready to be loaded
  68488. */
  68489. static get FilesToLoad(): {
  68490. [key: string]: File;
  68491. };
  68492. /**
  68493. * Callback called when a file is processed
  68494. */
  68495. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68496. private _engine;
  68497. private _currentScene;
  68498. private _sceneLoadedCallback;
  68499. private _progressCallback;
  68500. private _additionalRenderLoopLogicCallback;
  68501. private _textureLoadingCallback;
  68502. private _startingProcessingFilesCallback;
  68503. private _onReloadCallback;
  68504. private _errorCallback;
  68505. private _elementToMonitor;
  68506. private _sceneFileToLoad;
  68507. private _filesToLoad;
  68508. /**
  68509. * Creates a new FilesInput
  68510. * @param engine defines the rendering engine
  68511. * @param scene defines the hosting scene
  68512. * @param sceneLoadedCallback callback called when scene is loaded
  68513. * @param progressCallback callback called to track progress
  68514. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68515. * @param textureLoadingCallback callback called when a texture is loading
  68516. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68517. * @param onReloadCallback callback called when a reload is requested
  68518. * @param errorCallback callback call if an error occurs
  68519. */
  68520. 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);
  68521. private _dragEnterHandler;
  68522. private _dragOverHandler;
  68523. private _dropHandler;
  68524. /**
  68525. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68526. * @param elementToMonitor defines the DOM element to track
  68527. */
  68528. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68529. /**
  68530. * Release all associated resources
  68531. */
  68532. dispose(): void;
  68533. private renderFunction;
  68534. private drag;
  68535. private drop;
  68536. private _traverseFolder;
  68537. private _processFiles;
  68538. /**
  68539. * Load files from a drop event
  68540. * @param event defines the drop event to use as source
  68541. */
  68542. loadFiles(event: any): void;
  68543. private _processReload;
  68544. /**
  68545. * Reload the current scene from the loaded files
  68546. */
  68547. reload(): void;
  68548. }
  68549. }
  68550. declare module BABYLON {
  68551. /**
  68552. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68554. */
  68555. export class SceneOptimization {
  68556. /**
  68557. * Defines the priority of this optimization (0 by default which means first in the list)
  68558. */
  68559. priority: number;
  68560. /**
  68561. * Gets a string describing the action executed by the current optimization
  68562. * @returns description string
  68563. */
  68564. getDescription(): string;
  68565. /**
  68566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68567. * @param scene defines the current scene where to apply this optimization
  68568. * @param optimizer defines the current optimizer
  68569. * @returns true if everything that can be done was applied
  68570. */
  68571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68572. /**
  68573. * Creates the SceneOptimization object
  68574. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68575. * @param desc defines the description associated with the optimization
  68576. */
  68577. constructor(
  68578. /**
  68579. * Defines the priority of this optimization (0 by default which means first in the list)
  68580. */
  68581. priority?: number);
  68582. }
  68583. /**
  68584. * Defines an optimization used to reduce the size of render target textures
  68585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68586. */
  68587. export class TextureOptimization extends SceneOptimization {
  68588. /**
  68589. * Defines the priority of this optimization (0 by default which means first in the list)
  68590. */
  68591. priority: number;
  68592. /**
  68593. * 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
  68594. */
  68595. maximumSize: number;
  68596. /**
  68597. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68598. */
  68599. step: number;
  68600. /**
  68601. * Gets a string describing the action executed by the current optimization
  68602. * @returns description string
  68603. */
  68604. getDescription(): string;
  68605. /**
  68606. * Creates the TextureOptimization object
  68607. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68608. * @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
  68609. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68610. */
  68611. constructor(
  68612. /**
  68613. * Defines the priority of this optimization (0 by default which means first in the list)
  68614. */
  68615. priority?: number,
  68616. /**
  68617. * 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
  68618. */
  68619. maximumSize?: number,
  68620. /**
  68621. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68622. */
  68623. step?: number);
  68624. /**
  68625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68626. * @param scene defines the current scene where to apply this optimization
  68627. * @param optimizer defines the current optimizer
  68628. * @returns true if everything that can be done was applied
  68629. */
  68630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68631. }
  68632. /**
  68633. * Defines an optimization used to increase or decrease the rendering resolution
  68634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68635. */
  68636. export class HardwareScalingOptimization extends SceneOptimization {
  68637. /**
  68638. * Defines the priority of this optimization (0 by default which means first in the list)
  68639. */
  68640. priority: number;
  68641. /**
  68642. * Defines the maximum scale to use (2 by default)
  68643. */
  68644. maximumScale: number;
  68645. /**
  68646. * Defines the step to use between two passes (0.5 by default)
  68647. */
  68648. step: number;
  68649. private _currentScale;
  68650. private _directionOffset;
  68651. /**
  68652. * Gets a string describing the action executed by the current optimization
  68653. * @return description string
  68654. */
  68655. getDescription(): string;
  68656. /**
  68657. * Creates the HardwareScalingOptimization object
  68658. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68659. * @param maximumScale defines the maximum scale to use (2 by default)
  68660. * @param step defines the step to use between two passes (0.5 by default)
  68661. */
  68662. constructor(
  68663. /**
  68664. * Defines the priority of this optimization (0 by default which means first in the list)
  68665. */
  68666. priority?: number,
  68667. /**
  68668. * Defines the maximum scale to use (2 by default)
  68669. */
  68670. maximumScale?: number,
  68671. /**
  68672. * Defines the step to use between two passes (0.5 by default)
  68673. */
  68674. step?: number);
  68675. /**
  68676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68677. * @param scene defines the current scene where to apply this optimization
  68678. * @param optimizer defines the current optimizer
  68679. * @returns true if everything that can be done was applied
  68680. */
  68681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68682. }
  68683. /**
  68684. * Defines an optimization used to remove shadows
  68685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68686. */
  68687. export class ShadowsOptimization extends SceneOptimization {
  68688. /**
  68689. * Gets a string describing the action executed by the current optimization
  68690. * @return description string
  68691. */
  68692. getDescription(): string;
  68693. /**
  68694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68695. * @param scene defines the current scene where to apply this optimization
  68696. * @param optimizer defines the current optimizer
  68697. * @returns true if everything that can be done was applied
  68698. */
  68699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68700. }
  68701. /**
  68702. * Defines an optimization used to turn post-processes off
  68703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68704. */
  68705. export class PostProcessesOptimization extends SceneOptimization {
  68706. /**
  68707. * Gets a string describing the action executed by the current optimization
  68708. * @return description string
  68709. */
  68710. getDescription(): string;
  68711. /**
  68712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68713. * @param scene defines the current scene where to apply this optimization
  68714. * @param optimizer defines the current optimizer
  68715. * @returns true if everything that can be done was applied
  68716. */
  68717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68718. }
  68719. /**
  68720. * Defines an optimization used to turn lens flares off
  68721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68722. */
  68723. export class LensFlaresOptimization extends SceneOptimization {
  68724. /**
  68725. * Gets a string describing the action executed by the current optimization
  68726. * @return description string
  68727. */
  68728. getDescription(): string;
  68729. /**
  68730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68731. * @param scene defines the current scene where to apply this optimization
  68732. * @param optimizer defines the current optimizer
  68733. * @returns true if everything that can be done was applied
  68734. */
  68735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68736. }
  68737. /**
  68738. * Defines an optimization based on user defined callback.
  68739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68740. */
  68741. export class CustomOptimization extends SceneOptimization {
  68742. /**
  68743. * Callback called to apply the custom optimization.
  68744. */
  68745. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68746. /**
  68747. * Callback called to get custom description
  68748. */
  68749. onGetDescription: () => string;
  68750. /**
  68751. * Gets a string describing the action executed by the current optimization
  68752. * @returns description string
  68753. */
  68754. getDescription(): string;
  68755. /**
  68756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68757. * @param scene defines the current scene where to apply this optimization
  68758. * @param optimizer defines the current optimizer
  68759. * @returns true if everything that can be done was applied
  68760. */
  68761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68762. }
  68763. /**
  68764. * Defines an optimization used to turn particles off
  68765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68766. */
  68767. export class ParticlesOptimization extends SceneOptimization {
  68768. /**
  68769. * Gets a string describing the action executed by the current optimization
  68770. * @return description string
  68771. */
  68772. getDescription(): string;
  68773. /**
  68774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68775. * @param scene defines the current scene where to apply this optimization
  68776. * @param optimizer defines the current optimizer
  68777. * @returns true if everything that can be done was applied
  68778. */
  68779. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68780. }
  68781. /**
  68782. * Defines an optimization used to turn render targets off
  68783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68784. */
  68785. export class RenderTargetsOptimization extends SceneOptimization {
  68786. /**
  68787. * Gets a string describing the action executed by the current optimization
  68788. * @return description string
  68789. */
  68790. getDescription(): string;
  68791. /**
  68792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68793. * @param scene defines the current scene where to apply this optimization
  68794. * @param optimizer defines the current optimizer
  68795. * @returns true if everything that can be done was applied
  68796. */
  68797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68798. }
  68799. /**
  68800. * Defines an optimization used to merge meshes with compatible materials
  68801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68802. */
  68803. export class MergeMeshesOptimization extends SceneOptimization {
  68804. private static _UpdateSelectionTree;
  68805. /**
  68806. * Gets or sets a boolean which defines if optimization octree has to be updated
  68807. */
  68808. static get UpdateSelectionTree(): boolean;
  68809. /**
  68810. * Gets or sets a boolean which defines if optimization octree has to be updated
  68811. */
  68812. static set UpdateSelectionTree(value: boolean);
  68813. /**
  68814. * Gets a string describing the action executed by the current optimization
  68815. * @return description string
  68816. */
  68817. getDescription(): string;
  68818. private _canBeMerged;
  68819. /**
  68820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68821. * @param scene defines the current scene where to apply this optimization
  68822. * @param optimizer defines the current optimizer
  68823. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68824. * @returns true if everything that can be done was applied
  68825. */
  68826. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68827. }
  68828. /**
  68829. * Defines a list of options used by SceneOptimizer
  68830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68831. */
  68832. export class SceneOptimizerOptions {
  68833. /**
  68834. * Defines the target frame rate to reach (60 by default)
  68835. */
  68836. targetFrameRate: number;
  68837. /**
  68838. * Defines the interval between two checkes (2000ms by default)
  68839. */
  68840. trackerDuration: number;
  68841. /**
  68842. * Gets the list of optimizations to apply
  68843. */
  68844. optimizations: SceneOptimization[];
  68845. /**
  68846. * Creates a new list of options used by SceneOptimizer
  68847. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68848. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68849. */
  68850. constructor(
  68851. /**
  68852. * Defines the target frame rate to reach (60 by default)
  68853. */
  68854. targetFrameRate?: number,
  68855. /**
  68856. * Defines the interval between two checkes (2000ms by default)
  68857. */
  68858. trackerDuration?: number);
  68859. /**
  68860. * Add a new optimization
  68861. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68862. * @returns the current SceneOptimizerOptions
  68863. */
  68864. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68865. /**
  68866. * Add a new custom optimization
  68867. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68868. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68870. * @returns the current SceneOptimizerOptions
  68871. */
  68872. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68873. /**
  68874. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68875. * @param targetFrameRate defines the target frame rate (60 by default)
  68876. * @returns a SceneOptimizerOptions object
  68877. */
  68878. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68879. /**
  68880. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68881. * @param targetFrameRate defines the target frame rate (60 by default)
  68882. * @returns a SceneOptimizerOptions object
  68883. */
  68884. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68885. /**
  68886. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68887. * @param targetFrameRate defines the target frame rate (60 by default)
  68888. * @returns a SceneOptimizerOptions object
  68889. */
  68890. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68891. }
  68892. /**
  68893. * Class used to run optimizations in order to reach a target frame rate
  68894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68895. */
  68896. export class SceneOptimizer implements IDisposable {
  68897. private _isRunning;
  68898. private _options;
  68899. private _scene;
  68900. private _currentPriorityLevel;
  68901. private _targetFrameRate;
  68902. private _trackerDuration;
  68903. private _currentFrameRate;
  68904. private _sceneDisposeObserver;
  68905. private _improvementMode;
  68906. /**
  68907. * Defines an observable called when the optimizer reaches the target frame rate
  68908. */
  68909. onSuccessObservable: Observable<SceneOptimizer>;
  68910. /**
  68911. * Defines an observable called when the optimizer enables an optimization
  68912. */
  68913. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68914. /**
  68915. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68916. */
  68917. onFailureObservable: Observable<SceneOptimizer>;
  68918. /**
  68919. * Gets a boolean indicating if the optimizer is in improvement mode
  68920. */
  68921. get isInImprovementMode(): boolean;
  68922. /**
  68923. * Gets the current priority level (0 at start)
  68924. */
  68925. get currentPriorityLevel(): number;
  68926. /**
  68927. * Gets the current frame rate checked by the SceneOptimizer
  68928. */
  68929. get currentFrameRate(): number;
  68930. /**
  68931. * Gets or sets the current target frame rate (60 by default)
  68932. */
  68933. get targetFrameRate(): number;
  68934. /**
  68935. * Gets or sets the current target frame rate (60 by default)
  68936. */
  68937. set targetFrameRate(value: number);
  68938. /**
  68939. * Gets or sets the current interval between two checks (every 2000ms by default)
  68940. */
  68941. get trackerDuration(): number;
  68942. /**
  68943. * Gets or sets the current interval between two checks (every 2000ms by default)
  68944. */
  68945. set trackerDuration(value: number);
  68946. /**
  68947. * Gets the list of active optimizations
  68948. */
  68949. get optimizations(): SceneOptimization[];
  68950. /**
  68951. * Creates a new SceneOptimizer
  68952. * @param scene defines the scene to work on
  68953. * @param options defines the options to use with the SceneOptimizer
  68954. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68955. * @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)
  68956. */
  68957. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68958. /**
  68959. * Stops the current optimizer
  68960. */
  68961. stop(): void;
  68962. /**
  68963. * Reset the optimizer to initial step (current priority level = 0)
  68964. */
  68965. reset(): void;
  68966. /**
  68967. * Start the optimizer. By default it will try to reach a specific framerate
  68968. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68969. */
  68970. start(): void;
  68971. private _checkCurrentState;
  68972. /**
  68973. * Release all resources
  68974. */
  68975. dispose(): void;
  68976. /**
  68977. * Helper function to create a SceneOptimizer with one single line of code
  68978. * @param scene defines the scene to work on
  68979. * @param options defines the options to use with the SceneOptimizer
  68980. * @param onSuccess defines a callback to call on success
  68981. * @param onFailure defines a callback to call on failure
  68982. * @returns the new SceneOptimizer object
  68983. */
  68984. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68985. }
  68986. }
  68987. declare module BABYLON {
  68988. /**
  68989. * Class used to serialize a scene into a string
  68990. */
  68991. export class SceneSerializer {
  68992. /**
  68993. * Clear cache used by a previous serialization
  68994. */
  68995. static ClearCache(): void;
  68996. /**
  68997. * Serialize a scene into a JSON compatible object
  68998. * @param scene defines the scene to serialize
  68999. * @returns a JSON compatible object
  69000. */
  69001. static Serialize(scene: Scene): any;
  69002. /**
  69003. * Serialize a mesh into a JSON compatible object
  69004. * @param toSerialize defines the mesh to serialize
  69005. * @param withParents defines if parents must be serialized as well
  69006. * @param withChildren defines if children must be serialized as well
  69007. * @returns a JSON compatible object
  69008. */
  69009. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69010. }
  69011. }
  69012. declare module BABYLON {
  69013. /**
  69014. * Class used to host texture specific utilities
  69015. */
  69016. export class TextureTools {
  69017. /**
  69018. * Uses the GPU to create a copy texture rescaled at a given size
  69019. * @param texture Texture to copy from
  69020. * @param width defines the desired width
  69021. * @param height defines the desired height
  69022. * @param useBilinearMode defines if bilinear mode has to be used
  69023. * @return the generated texture
  69024. */
  69025. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69026. }
  69027. }
  69028. declare module BABYLON {
  69029. /**
  69030. * This represents the different options available for the video capture.
  69031. */
  69032. export interface VideoRecorderOptions {
  69033. /** Defines the mime type of the video. */
  69034. mimeType: string;
  69035. /** Defines the FPS the video should be recorded at. */
  69036. fps: number;
  69037. /** Defines the chunk size for the recording data. */
  69038. recordChunckSize: number;
  69039. /** The audio tracks to attach to the recording. */
  69040. audioTracks?: MediaStreamTrack[];
  69041. }
  69042. /**
  69043. * This can help with recording videos from BabylonJS.
  69044. * This is based on the available WebRTC functionalities of the browser.
  69045. *
  69046. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69047. */
  69048. export class VideoRecorder {
  69049. private static readonly _defaultOptions;
  69050. /**
  69051. * Returns whether or not the VideoRecorder is available in your browser.
  69052. * @param engine Defines the Babylon Engine.
  69053. * @returns true if supported otherwise false.
  69054. */
  69055. static IsSupported(engine: Engine): boolean;
  69056. private readonly _options;
  69057. private _canvas;
  69058. private _mediaRecorder;
  69059. private _recordedChunks;
  69060. private _fileName;
  69061. private _resolve;
  69062. private _reject;
  69063. /**
  69064. * True when a recording is already in progress.
  69065. */
  69066. get isRecording(): boolean;
  69067. /**
  69068. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69069. * @param engine Defines the BabylonJS Engine you wish to record.
  69070. * @param options Defines options that can be used to customize the capture.
  69071. */
  69072. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69073. /**
  69074. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69075. */
  69076. stopRecording(): void;
  69077. /**
  69078. * Starts recording the canvas for a max duration specified in parameters.
  69079. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69080. * If null no automatic download will start and you can rely on the promise to get the data back.
  69081. * @param maxDuration Defines the maximum recording time in seconds.
  69082. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69083. * @return A promise callback at the end of the recording with the video data in Blob.
  69084. */
  69085. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69086. /**
  69087. * Releases internal resources used during the recording.
  69088. */
  69089. dispose(): void;
  69090. private _handleDataAvailable;
  69091. private _handleError;
  69092. private _handleStop;
  69093. }
  69094. }
  69095. declare module BABYLON {
  69096. /**
  69097. * Class containing a set of static utilities functions for screenshots
  69098. */
  69099. export class ScreenshotTools {
  69100. /**
  69101. * Captures a screenshot of the current rendering
  69102. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69103. * @param engine defines the rendering engine
  69104. * @param camera defines the source camera
  69105. * @param size This parameter can be set to a single number or to an object with the
  69106. * following (optional) properties: precision, width, height. If a single number is passed,
  69107. * it will be used for both width and height. If an object is passed, the screenshot size
  69108. * will be derived from the parameters. The precision property is a multiplier allowing
  69109. * rendering at a higher or lower resolution
  69110. * @param successCallback defines the callback receives a single parameter which contains the
  69111. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69112. * src parameter of an <img> to display it
  69113. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69114. * Check your browser for supported MIME types
  69115. */
  69116. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69117. /**
  69118. * Captures a screenshot of the current rendering
  69119. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69120. * @param engine defines the rendering engine
  69121. * @param camera defines the source camera
  69122. * @param size This parameter can be set to a single number or to an object with the
  69123. * following (optional) properties: precision, width, height. If a single number is passed,
  69124. * it will be used for both width and height. If an object is passed, the screenshot size
  69125. * will be derived from the parameters. The precision property is a multiplier allowing
  69126. * rendering at a higher or lower resolution
  69127. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69128. * Check your browser for supported MIME types
  69129. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69130. * to the src parameter of an <img> to display it
  69131. */
  69132. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69133. /**
  69134. * Generates an image screenshot from the specified camera.
  69135. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69136. * @param engine The engine to use for rendering
  69137. * @param camera The camera to use for rendering
  69138. * @param size This parameter can be set to a single number or to an object with the
  69139. * following (optional) properties: precision, width, height. If a single number is passed,
  69140. * it will be used for both width and height. If an object is passed, the screenshot size
  69141. * will be derived from the parameters. The precision property is a multiplier allowing
  69142. * rendering at a higher or lower resolution
  69143. * @param successCallback The callback receives a single parameter which contains the
  69144. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69145. * src parameter of an <img> to display it
  69146. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69147. * Check your browser for supported MIME types
  69148. * @param samples Texture samples (default: 1)
  69149. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69150. * @param fileName A name for for the downloaded file.
  69151. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69152. */
  69153. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69154. /**
  69155. * Generates an image screenshot from the specified camera.
  69156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69157. * @param engine The engine to use for rendering
  69158. * @param camera The camera to use for rendering
  69159. * @param size This parameter can be set to a single number or to an object with the
  69160. * following (optional) properties: precision, width, height. If a single number is passed,
  69161. * it will be used for both width and height. If an object is passed, the screenshot size
  69162. * will be derived from the parameters. The precision property is a multiplier allowing
  69163. * rendering at a higher or lower resolution
  69164. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69165. * Check your browser for supported MIME types
  69166. * @param samples Texture samples (default: 1)
  69167. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69168. * @param fileName A name for for the downloaded file.
  69169. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69170. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69171. * to the src parameter of an <img> to display it
  69172. */
  69173. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69174. /**
  69175. * Gets height and width for screenshot size
  69176. * @private
  69177. */
  69178. private static _getScreenshotSize;
  69179. }
  69180. }
  69181. declare module BABYLON {
  69182. /**
  69183. * Interface for a data buffer
  69184. */
  69185. export interface IDataBuffer {
  69186. /**
  69187. * Reads bytes from the data buffer.
  69188. * @param byteOffset The byte offset to read
  69189. * @param byteLength The byte length to read
  69190. * @returns A promise that resolves when the bytes are read
  69191. */
  69192. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69193. /**
  69194. * The byte length of the buffer.
  69195. */
  69196. readonly byteLength: number;
  69197. }
  69198. /**
  69199. * Utility class for reading from a data buffer
  69200. */
  69201. export class DataReader {
  69202. /**
  69203. * The data buffer associated with this data reader.
  69204. */
  69205. readonly buffer: IDataBuffer;
  69206. /**
  69207. * The current byte offset from the beginning of the data buffer.
  69208. */
  69209. byteOffset: number;
  69210. private _dataView;
  69211. private _dataByteOffset;
  69212. /**
  69213. * Constructor
  69214. * @param buffer The buffer to read
  69215. */
  69216. constructor(buffer: IDataBuffer);
  69217. /**
  69218. * Loads the given byte length.
  69219. * @param byteLength The byte length to load
  69220. * @returns A promise that resolves when the load is complete
  69221. */
  69222. loadAsync(byteLength: number): Promise<void>;
  69223. /**
  69224. * Read a unsigned 32-bit integer from the currently loaded data range.
  69225. * @returns The 32-bit integer read
  69226. */
  69227. readUint32(): number;
  69228. /**
  69229. * Read a byte array from the currently loaded data range.
  69230. * @param byteLength The byte length to read
  69231. * @returns The byte array read
  69232. */
  69233. readUint8Array(byteLength: number): Uint8Array;
  69234. /**
  69235. * Read a string from the currently loaded data range.
  69236. * @param byteLength The byte length to read
  69237. * @returns The string read
  69238. */
  69239. readString(byteLength: number): string;
  69240. /**
  69241. * Skips the given byte length the currently loaded data range.
  69242. * @param byteLength The byte length to skip
  69243. */
  69244. skipBytes(byteLength: number): void;
  69245. }
  69246. }
  69247. declare module BABYLON {
  69248. /**
  69249. * Class for storing data to local storage if available or in-memory storage otherwise
  69250. */
  69251. export class DataStorage {
  69252. private static _Storage;
  69253. private static _GetStorage;
  69254. /**
  69255. * Reads a string from the data storage
  69256. * @param key The key to read
  69257. * @param defaultValue The value if the key doesn't exist
  69258. * @returns The string value
  69259. */
  69260. static ReadString(key: string, defaultValue: string): string;
  69261. /**
  69262. * Writes a string to the data storage
  69263. * @param key The key to write
  69264. * @param value The value to write
  69265. */
  69266. static WriteString(key: string, value: string): void;
  69267. /**
  69268. * Reads a boolean from the data storage
  69269. * @param key The key to read
  69270. * @param defaultValue The value if the key doesn't exist
  69271. * @returns The boolean value
  69272. */
  69273. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69274. /**
  69275. * Writes a boolean to the data storage
  69276. * @param key The key to write
  69277. * @param value The value to write
  69278. */
  69279. static WriteBoolean(key: string, value: boolean): void;
  69280. /**
  69281. * Reads a number from the data storage
  69282. * @param key The key to read
  69283. * @param defaultValue The value if the key doesn't exist
  69284. * @returns The number value
  69285. */
  69286. static ReadNumber(key: string, defaultValue: number): number;
  69287. /**
  69288. * Writes a number to the data storage
  69289. * @param key The key to write
  69290. * @param value The value to write
  69291. */
  69292. static WriteNumber(key: string, value: number): void;
  69293. }
  69294. }
  69295. declare module BABYLON {
  69296. /**
  69297. * Options used for hit testing
  69298. */
  69299. export interface IWebXRLegacyHitTestOptions {
  69300. /**
  69301. * Only test when user interacted with the scene. Default - hit test every frame
  69302. */
  69303. testOnPointerDownOnly?: boolean;
  69304. /**
  69305. * The node to use to transform the local results to world coordinates
  69306. */
  69307. worldParentNode?: TransformNode;
  69308. }
  69309. /**
  69310. * Interface defining the babylon result of raycasting/hit-test
  69311. */
  69312. export interface IWebXRLegacyHitResult {
  69313. /**
  69314. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69315. */
  69316. transformationMatrix: Matrix;
  69317. /**
  69318. * The native hit test result
  69319. */
  69320. xrHitResult: XRHitResult | XRHitTestResult;
  69321. }
  69322. /**
  69323. * The currently-working hit-test module.
  69324. * Hit test (or Ray-casting) is used to interact with the real world.
  69325. * For further information read here - https://github.com/immersive-web/hit-test
  69326. */
  69327. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69328. /**
  69329. * options to use when constructing this feature
  69330. */
  69331. readonly options: IWebXRLegacyHitTestOptions;
  69332. private _direction;
  69333. private _mat;
  69334. private _onSelectEnabled;
  69335. private _origin;
  69336. /**
  69337. * The module's name
  69338. */
  69339. static readonly Name: string;
  69340. /**
  69341. * The (Babylon) version of this module.
  69342. * This is an integer representing the implementation version.
  69343. * This number does not correspond to the WebXR specs version
  69344. */
  69345. static readonly Version: number;
  69346. /**
  69347. * Populated with the last native XR Hit Results
  69348. */
  69349. lastNativeXRHitResults: XRHitResult[];
  69350. /**
  69351. * Triggered when new babylon (transformed) hit test results are available
  69352. */
  69353. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69354. /**
  69355. * Creates a new instance of the (legacy version) hit test feature
  69356. * @param _xrSessionManager an instance of WebXRSessionManager
  69357. * @param options options to use when constructing this feature
  69358. */
  69359. constructor(_xrSessionManager: WebXRSessionManager,
  69360. /**
  69361. * options to use when constructing this feature
  69362. */
  69363. options?: IWebXRLegacyHitTestOptions);
  69364. /**
  69365. * execute a hit test with an XR Ray
  69366. *
  69367. * @param xrSession a native xrSession that will execute this hit test
  69368. * @param xrRay the ray (position and direction) to use for ray-casting
  69369. * @param referenceSpace native XR reference space to use for the hit-test
  69370. * @param filter filter function that will filter the results
  69371. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69372. */
  69373. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69374. /**
  69375. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69376. * @param event the (select) event to use to select with
  69377. * @param referenceSpace the reference space to use for this hit test
  69378. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69379. */
  69380. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69381. /**
  69382. * attach this feature
  69383. * Will usually be called by the features manager
  69384. *
  69385. * @returns true if successful.
  69386. */
  69387. attach(): boolean;
  69388. /**
  69389. * detach this feature.
  69390. * Will usually be called by the features manager
  69391. *
  69392. * @returns true if successful.
  69393. */
  69394. detach(): boolean;
  69395. /**
  69396. * Dispose this feature and all of the resources attached
  69397. */
  69398. dispose(): void;
  69399. protected _onXRFrame(frame: XRFrame): void;
  69400. private _onHitTestResults;
  69401. private _onSelect;
  69402. }
  69403. }
  69404. declare module BABYLON {
  69405. /**
  69406. * Options used in the plane detector module
  69407. */
  69408. export interface IWebXRPlaneDetectorOptions {
  69409. /**
  69410. * The node to use to transform the local results to world coordinates
  69411. */
  69412. worldParentNode?: TransformNode;
  69413. }
  69414. /**
  69415. * A babylon interface for a WebXR plane.
  69416. * A Plane is actually a polygon, built from N points in space
  69417. *
  69418. * Supported in chrome 79, not supported in canary 81 ATM
  69419. */
  69420. export interface IWebXRPlane {
  69421. /**
  69422. * a babylon-assigned ID for this polygon
  69423. */
  69424. id: number;
  69425. /**
  69426. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69427. */
  69428. polygonDefinition: Array<Vector3>;
  69429. /**
  69430. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69431. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69432. */
  69433. transformationMatrix: Matrix;
  69434. /**
  69435. * the native xr-plane object
  69436. */
  69437. xrPlane: XRPlane;
  69438. }
  69439. /**
  69440. * The plane detector is used to detect planes in the real world when in AR
  69441. * For more information see https://github.com/immersive-web/real-world-geometry/
  69442. */
  69443. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69444. private _options;
  69445. private _detectedPlanes;
  69446. private _enabled;
  69447. private _lastFrameDetected;
  69448. /**
  69449. * The module's name
  69450. */
  69451. static readonly Name: string;
  69452. /**
  69453. * The (Babylon) version of this module.
  69454. * This is an integer representing the implementation version.
  69455. * This number does not correspond to the WebXR specs version
  69456. */
  69457. static readonly Version: number;
  69458. /**
  69459. * Observers registered here will be executed when a new plane was added to the session
  69460. */
  69461. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69462. /**
  69463. * Observers registered here will be executed when a plane is no longer detected in the session
  69464. */
  69465. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69466. /**
  69467. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69468. * This can execute N times every frame
  69469. */
  69470. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69471. /**
  69472. * construct a new Plane Detector
  69473. * @param _xrSessionManager an instance of xr Session manager
  69474. * @param _options configuration to use when constructing this feature
  69475. */
  69476. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69477. /**
  69478. * Dispose this feature and all of the resources attached
  69479. */
  69480. dispose(): void;
  69481. protected _onXRFrame(frame: XRFrame): void;
  69482. private _init;
  69483. private _updatePlaneWithXRPlane;
  69484. /**
  69485. * avoiding using Array.find for global support.
  69486. * @param xrPlane the plane to find in the array
  69487. */
  69488. private findIndexInPlaneArray;
  69489. }
  69490. }
  69491. declare module BABYLON {
  69492. /**
  69493. * Configuration options of the anchor system
  69494. */
  69495. export interface IWebXRAnchorSystemOptions {
  69496. /**
  69497. * Should a new anchor be added every time a select event is triggered
  69498. */
  69499. addAnchorOnSelect?: boolean;
  69500. /**
  69501. * should the anchor system use plane detection.
  69502. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69503. */
  69504. usePlaneDetection?: boolean;
  69505. /**
  69506. * a node that will be used to convert local to world coordinates
  69507. */
  69508. worldParentNode?: TransformNode;
  69509. }
  69510. /**
  69511. * A babylon container for an XR Anchor
  69512. */
  69513. export interface IWebXRAnchor {
  69514. /**
  69515. * A babylon-assigned ID for this anchor
  69516. */
  69517. id: number;
  69518. /**
  69519. * Transformation matrix to apply to an object attached to this anchor
  69520. */
  69521. transformationMatrix: Matrix;
  69522. /**
  69523. * The native anchor object
  69524. */
  69525. xrAnchor: XRAnchor;
  69526. }
  69527. /**
  69528. * An implementation of the anchor system of WebXR.
  69529. * Note that the current documented implementation is not available in any browser. Future implementations
  69530. * will use the frame to create an anchor and not the session or a detected plane
  69531. * For further information see https://github.com/immersive-web/anchors/
  69532. */
  69533. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69534. private _options;
  69535. private _enabled;
  69536. private _hitTestModule;
  69537. private _lastFrameDetected;
  69538. private _onSelect;
  69539. private _planeDetector;
  69540. private _trackedAnchors;
  69541. /**
  69542. * The module's name
  69543. */
  69544. static readonly Name: string;
  69545. /**
  69546. * The (Babylon) version of this module.
  69547. * This is an integer representing the implementation version.
  69548. * This number does not correspond to the WebXR specs version
  69549. */
  69550. static readonly Version: number;
  69551. /**
  69552. * Observers registered here will be executed when a new anchor was added to the session
  69553. */
  69554. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69555. /**
  69556. * Observers registered here will be executed when an anchor was removed from the session
  69557. */
  69558. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69559. /**
  69560. * Observers registered here will be executed when an existing anchor updates
  69561. * This can execute N times every frame
  69562. */
  69563. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69564. /**
  69565. * constructs a new anchor system
  69566. * @param _xrSessionManager an instance of WebXRSessionManager
  69567. * @param _options configuration object for this feature
  69568. */
  69569. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69570. /**
  69571. * Add anchor at a specific XR point.
  69572. *
  69573. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69574. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69575. * @returns a promise the fulfills when the anchor was created
  69576. */
  69577. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69578. /**
  69579. * attach this feature
  69580. * Will usually be called by the features manager
  69581. *
  69582. * @returns true if successful.
  69583. */
  69584. attach(): boolean;
  69585. /**
  69586. * detach this feature.
  69587. * Will usually be called by the features manager
  69588. *
  69589. * @returns true if successful.
  69590. */
  69591. detach(): boolean;
  69592. /**
  69593. * Dispose this feature and all of the resources attached
  69594. */
  69595. dispose(): void;
  69596. /**
  69597. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69598. * @param hitTestModule the hit-test module to use.
  69599. */
  69600. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69601. /**
  69602. * set the plane detector to use in order to create anchors from frames
  69603. * @param planeDetector the plane-detector module to use
  69604. * @param enable enable plane-anchors. default is true
  69605. */
  69606. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69607. protected _onXRFrame(frame: XRFrame): void;
  69608. /**
  69609. * avoiding using Array.find for global support.
  69610. * @param xrAnchor the plane to find in the array
  69611. */
  69612. private _findIndexInAnchorArray;
  69613. private _updateAnchorWithXRFrame;
  69614. }
  69615. }
  69616. declare module BABYLON {
  69617. /**
  69618. * Options interface for the background remover plugin
  69619. */
  69620. export interface IWebXRBackgroundRemoverOptions {
  69621. /**
  69622. * Further background meshes to disable when entering AR
  69623. */
  69624. backgroundMeshes?: AbstractMesh[];
  69625. /**
  69626. * flags to configure the removal of the environment helper.
  69627. * If not set, the entire background will be removed. If set, flags should be set as well.
  69628. */
  69629. environmentHelperRemovalFlags?: {
  69630. /**
  69631. * Should the skybox be removed (default false)
  69632. */
  69633. skyBox?: boolean;
  69634. /**
  69635. * Should the ground be removed (default false)
  69636. */
  69637. ground?: boolean;
  69638. };
  69639. /**
  69640. * don't disable the environment helper
  69641. */
  69642. ignoreEnvironmentHelper?: boolean;
  69643. }
  69644. /**
  69645. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69646. */
  69647. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69648. /**
  69649. * read-only options to be used in this module
  69650. */
  69651. readonly options: IWebXRBackgroundRemoverOptions;
  69652. /**
  69653. * The module's name
  69654. */
  69655. static readonly Name: string;
  69656. /**
  69657. * The (Babylon) version of this module.
  69658. * This is an integer representing the implementation version.
  69659. * This number does not correspond to the WebXR specs version
  69660. */
  69661. static readonly Version: number;
  69662. /**
  69663. * registered observers will be triggered when the background state changes
  69664. */
  69665. onBackgroundStateChangedObservable: Observable<boolean>;
  69666. /**
  69667. * constructs a new background remover module
  69668. * @param _xrSessionManager the session manager for this module
  69669. * @param options read-only options to be used in this module
  69670. */
  69671. constructor(_xrSessionManager: WebXRSessionManager,
  69672. /**
  69673. * read-only options to be used in this module
  69674. */
  69675. options?: IWebXRBackgroundRemoverOptions);
  69676. /**
  69677. * attach this feature
  69678. * Will usually be called by the features manager
  69679. *
  69680. * @returns true if successful.
  69681. */
  69682. attach(): boolean;
  69683. /**
  69684. * detach this feature.
  69685. * Will usually be called by the features manager
  69686. *
  69687. * @returns true if successful.
  69688. */
  69689. detach(): boolean;
  69690. /**
  69691. * Dispose this feature and all of the resources attached
  69692. */
  69693. dispose(): void;
  69694. protected _onXRFrame(_xrFrame: XRFrame): void;
  69695. private _setBackgroundState;
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Options for the controller physics feature
  69701. */
  69702. export class IWebXRControllerPhysicsOptions {
  69703. /**
  69704. * Should the headset get its own impostor
  69705. */
  69706. enableHeadsetImpostor?: boolean;
  69707. /**
  69708. * Optional parameters for the headset impostor
  69709. */
  69710. headsetImpostorParams?: {
  69711. /**
  69712. * The type of impostor to create. Default is sphere
  69713. */
  69714. impostorType: number;
  69715. /**
  69716. * the size of the impostor. Defaults to 10cm
  69717. */
  69718. impostorSize?: number | {
  69719. width: number;
  69720. height: number;
  69721. depth: number;
  69722. };
  69723. /**
  69724. * Friction definitions
  69725. */
  69726. friction?: number;
  69727. /**
  69728. * Restitution
  69729. */
  69730. restitution?: number;
  69731. };
  69732. /**
  69733. * The physics properties of the future impostors
  69734. */
  69735. physicsProperties?: {
  69736. /**
  69737. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69738. * Note that this requires a physics engine that supports mesh impostors!
  69739. */
  69740. useControllerMesh?: boolean;
  69741. /**
  69742. * The type of impostor to create. Default is sphere
  69743. */
  69744. impostorType?: number;
  69745. /**
  69746. * the size of the impostor. Defaults to 10cm
  69747. */
  69748. impostorSize?: number | {
  69749. width: number;
  69750. height: number;
  69751. depth: number;
  69752. };
  69753. /**
  69754. * Friction definitions
  69755. */
  69756. friction?: number;
  69757. /**
  69758. * Restitution
  69759. */
  69760. restitution?: number;
  69761. };
  69762. /**
  69763. * the xr input to use with this pointer selection
  69764. */
  69765. xrInput: WebXRInput;
  69766. }
  69767. /**
  69768. * Add physics impostor to your webxr controllers,
  69769. * including naive calculation of their linear and angular velocity
  69770. */
  69771. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69772. private readonly _options;
  69773. private _attachController;
  69774. private _controllers;
  69775. private _debugMode;
  69776. private _delta;
  69777. private _headsetImpostor?;
  69778. private _headsetMesh?;
  69779. private _lastTimestamp;
  69780. private _tmpQuaternion;
  69781. private _tmpVector;
  69782. /**
  69783. * The module's name
  69784. */
  69785. static readonly Name: string;
  69786. /**
  69787. * The (Babylon) version of this module.
  69788. * This is an integer representing the implementation version.
  69789. * This number does not correspond to the webxr specs version
  69790. */
  69791. static readonly Version: number;
  69792. /**
  69793. * Construct a new Controller Physics Feature
  69794. * @param _xrSessionManager the corresponding xr session manager
  69795. * @param _options options to create this feature with
  69796. */
  69797. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69798. /**
  69799. * @hidden
  69800. * enable debugging - will show console outputs and the impostor mesh
  69801. */
  69802. _enablePhysicsDebug(): void;
  69803. /**
  69804. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69805. * @param xrController the controller to add
  69806. */
  69807. addController(xrController: WebXRInputSource): void;
  69808. /**
  69809. * attach this feature
  69810. * Will usually be called by the features manager
  69811. *
  69812. * @returns true if successful.
  69813. */
  69814. attach(): boolean;
  69815. /**
  69816. * detach this feature.
  69817. * Will usually be called by the features manager
  69818. *
  69819. * @returns true if successful.
  69820. */
  69821. detach(): boolean;
  69822. /**
  69823. * Get the headset impostor, if enabled
  69824. * @returns the impostor
  69825. */
  69826. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69827. /**
  69828. * Get the physics impostor of a specific controller.
  69829. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69830. * @param controller the controller or the controller id of which to get the impostor
  69831. * @returns the impostor or null
  69832. */
  69833. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69834. /**
  69835. * Update the physics properties provided in the constructor
  69836. * @param newProperties the new properties object
  69837. */
  69838. setPhysicsProperties(newProperties: {
  69839. impostorType?: number;
  69840. impostorSize?: number | {
  69841. width: number;
  69842. height: number;
  69843. depth: number;
  69844. };
  69845. friction?: number;
  69846. restitution?: number;
  69847. }): void;
  69848. protected _onXRFrame(_xrFrame: any): void;
  69849. private _detachController;
  69850. }
  69851. }
  69852. declare module BABYLON {
  69853. /**
  69854. * Options used for hit testing (version 2)
  69855. */
  69856. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  69857. /**
  69858. * Do not create a permanent hit test. Will usually be used when only
  69859. * transient inputs are needed.
  69860. */
  69861. disablePermanentHitTest?: boolean;
  69862. /**
  69863. * Enable transient (for example touch-based) hit test inspections
  69864. */
  69865. enableTransientHitTest?: boolean;
  69866. /**
  69867. * Offset ray for the permanent hit test
  69868. */
  69869. offsetRay?: Vector3;
  69870. /**
  69871. * Offset ray for the transient hit test
  69872. */
  69873. transientOffsetRay?: Vector3;
  69874. /**
  69875. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  69876. */
  69877. useReferenceSpace?: boolean;
  69878. }
  69879. /**
  69880. * Interface defining the babylon result of hit-test
  69881. */
  69882. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  69883. /**
  69884. * The input source that generated this hit test (if transient)
  69885. */
  69886. inputSource?: XRInputSource;
  69887. /**
  69888. * Is this a transient hit test
  69889. */
  69890. isTransient?: boolean;
  69891. /**
  69892. * Position of the hit test result
  69893. */
  69894. position: Vector3;
  69895. /**
  69896. * Rotation of the hit test result
  69897. */
  69898. rotationQuaternion: Quaternion;
  69899. }
  69900. /**
  69901. * The currently-working hit-test module.
  69902. * Hit test (or Ray-casting) is used to interact with the real world.
  69903. * For further information read here - https://github.com/immersive-web/hit-test
  69904. *
  69905. * Tested on chrome (mobile) 80.
  69906. */
  69907. export class WebXRHitTest extends WebXRAbstractFeature {
  69908. /**
  69909. * options to use when constructing this feature
  69910. */
  69911. readonly options: IWebXRHitTestOptions;
  69912. private _tmpMat;
  69913. private _tmpPos;
  69914. private _tmpQuat;
  69915. private _transientXrHitTestSource;
  69916. private _xrHitTestSource;
  69917. private initHitTestSource;
  69918. /**
  69919. * The module's name
  69920. */
  69921. static readonly Name: string;
  69922. /**
  69923. * The (Babylon) version of this module.
  69924. * This is an integer representing the implementation version.
  69925. * This number does not correspond to the WebXR specs version
  69926. */
  69927. static readonly Version: number;
  69928. /**
  69929. * When set to true, each hit test will have its own position/rotation objects
  69930. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  69931. * the developers will clone them or copy them as they see fit.
  69932. */
  69933. autoCloneTransformation: boolean;
  69934. /**
  69935. * Populated with the last native XR Hit Results
  69936. */
  69937. lastNativeXRHitResults: XRHitResult[];
  69938. /**
  69939. * Triggered when new babylon (transformed) hit test results are available
  69940. */
  69941. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  69942. /**
  69943. * Use this to temporarily pause hit test checks.
  69944. */
  69945. paused: boolean;
  69946. /**
  69947. * Creates a new instance of the hit test feature
  69948. * @param _xrSessionManager an instance of WebXRSessionManager
  69949. * @param options options to use when constructing this feature
  69950. */
  69951. constructor(_xrSessionManager: WebXRSessionManager,
  69952. /**
  69953. * options to use when constructing this feature
  69954. */
  69955. options?: IWebXRHitTestOptions);
  69956. /**
  69957. * attach this feature
  69958. * Will usually be called by the features manager
  69959. *
  69960. * @returns true if successful.
  69961. */
  69962. attach(): boolean;
  69963. /**
  69964. * detach this feature.
  69965. * Will usually be called by the features manager
  69966. *
  69967. * @returns true if successful.
  69968. */
  69969. detach(): boolean;
  69970. /**
  69971. * Dispose this feature and all of the resources attached
  69972. */
  69973. dispose(): void;
  69974. protected _onXRFrame(frame: XRFrame): void;
  69975. private _processWebXRHitTestResult;
  69976. }
  69977. }
  69978. declare module BABYLON {
  69979. /**
  69980. * The motion controller class for all microsoft mixed reality controllers
  69981. */
  69982. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69983. protected readonly _mapping: {
  69984. defaultButton: {
  69985. "valueNodeName": string;
  69986. "unpressedNodeName": string;
  69987. "pressedNodeName": string;
  69988. };
  69989. defaultAxis: {
  69990. "valueNodeName": string;
  69991. "minNodeName": string;
  69992. "maxNodeName": string;
  69993. };
  69994. buttons: {
  69995. "xr-standard-trigger": {
  69996. "rootNodeName": string;
  69997. "componentProperty": string;
  69998. "states": string[];
  69999. };
  70000. "xr-standard-squeeze": {
  70001. "rootNodeName": string;
  70002. "componentProperty": string;
  70003. "states": string[];
  70004. };
  70005. "xr-standard-touchpad": {
  70006. "rootNodeName": string;
  70007. "labelAnchorNodeName": string;
  70008. "touchPointNodeName": string;
  70009. };
  70010. "xr-standard-thumbstick": {
  70011. "rootNodeName": string;
  70012. "componentProperty": string;
  70013. "states": string[];
  70014. };
  70015. };
  70016. axes: {
  70017. "xr-standard-touchpad": {
  70018. "x-axis": {
  70019. "rootNodeName": string;
  70020. };
  70021. "y-axis": {
  70022. "rootNodeName": string;
  70023. };
  70024. };
  70025. "xr-standard-thumbstick": {
  70026. "x-axis": {
  70027. "rootNodeName": string;
  70028. };
  70029. "y-axis": {
  70030. "rootNodeName": string;
  70031. };
  70032. };
  70033. };
  70034. };
  70035. /**
  70036. * The base url used to load the left and right controller models
  70037. */
  70038. static MODEL_BASE_URL: string;
  70039. /**
  70040. * The name of the left controller model file
  70041. */
  70042. static MODEL_LEFT_FILENAME: string;
  70043. /**
  70044. * The name of the right controller model file
  70045. */
  70046. static MODEL_RIGHT_FILENAME: string;
  70047. profileId: string;
  70048. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70049. protected _getFilenameAndPath(): {
  70050. filename: string;
  70051. path: string;
  70052. };
  70053. protected _getModelLoadingConstraints(): boolean;
  70054. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70055. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70056. protected _updateModel(): void;
  70057. }
  70058. }
  70059. declare module BABYLON {
  70060. /**
  70061. * The motion controller class for oculus touch (quest, rift).
  70062. * This class supports legacy mapping as well the standard xr mapping
  70063. */
  70064. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70065. private _forceLegacyControllers;
  70066. private _modelRootNode;
  70067. /**
  70068. * The base url used to load the left and right controller models
  70069. */
  70070. static MODEL_BASE_URL: string;
  70071. /**
  70072. * The name of the left controller model file
  70073. */
  70074. static MODEL_LEFT_FILENAME: string;
  70075. /**
  70076. * The name of the right controller model file
  70077. */
  70078. static MODEL_RIGHT_FILENAME: string;
  70079. /**
  70080. * Base Url for the Quest controller model.
  70081. */
  70082. static QUEST_MODEL_BASE_URL: string;
  70083. profileId: string;
  70084. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70085. protected _getFilenameAndPath(): {
  70086. filename: string;
  70087. path: string;
  70088. };
  70089. protected _getModelLoadingConstraints(): boolean;
  70090. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70091. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70092. protected _updateModel(): void;
  70093. /**
  70094. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70095. * between the touch and touch 2.
  70096. */
  70097. private _isQuest;
  70098. }
  70099. }
  70100. declare module BABYLON {
  70101. /**
  70102. * The motion controller class for the standard HTC-Vive controllers
  70103. */
  70104. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70105. private _modelRootNode;
  70106. /**
  70107. * The base url used to load the left and right controller models
  70108. */
  70109. static MODEL_BASE_URL: string;
  70110. /**
  70111. * File name for the controller model.
  70112. */
  70113. static MODEL_FILENAME: string;
  70114. profileId: string;
  70115. /**
  70116. * Create a new Vive motion controller object
  70117. * @param scene the scene to use to create this controller
  70118. * @param gamepadObject the corresponding gamepad object
  70119. * @param handness the handness of the controller
  70120. */
  70121. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70122. protected _getFilenameAndPath(): {
  70123. filename: string;
  70124. path: string;
  70125. };
  70126. protected _getModelLoadingConstraints(): boolean;
  70127. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70128. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70129. protected _updateModel(): void;
  70130. }
  70131. }
  70132. declare module BABYLON {
  70133. /**
  70134. * A cursor which tracks a point on a path
  70135. */
  70136. export class PathCursor {
  70137. private path;
  70138. /**
  70139. * Stores path cursor callbacks for when an onchange event is triggered
  70140. */
  70141. private _onchange;
  70142. /**
  70143. * The value of the path cursor
  70144. */
  70145. value: number;
  70146. /**
  70147. * The animation array of the path cursor
  70148. */
  70149. animations: Animation[];
  70150. /**
  70151. * Initializes the path cursor
  70152. * @param path The path to track
  70153. */
  70154. constructor(path: Path2);
  70155. /**
  70156. * Gets the cursor point on the path
  70157. * @returns A point on the path cursor at the cursor location
  70158. */
  70159. getPoint(): Vector3;
  70160. /**
  70161. * Moves the cursor ahead by the step amount
  70162. * @param step The amount to move the cursor forward
  70163. * @returns This path cursor
  70164. */
  70165. moveAhead(step?: number): PathCursor;
  70166. /**
  70167. * Moves the cursor behind by the step amount
  70168. * @param step The amount to move the cursor back
  70169. * @returns This path cursor
  70170. */
  70171. moveBack(step?: number): PathCursor;
  70172. /**
  70173. * Moves the cursor by the step amount
  70174. * If the step amount is greater than one, an exception is thrown
  70175. * @param step The amount to move the cursor
  70176. * @returns This path cursor
  70177. */
  70178. move(step: number): PathCursor;
  70179. /**
  70180. * Ensures that the value is limited between zero and one
  70181. * @returns This path cursor
  70182. */
  70183. private ensureLimits;
  70184. /**
  70185. * Runs onchange callbacks on change (used by the animation engine)
  70186. * @returns This path cursor
  70187. */
  70188. private raiseOnChange;
  70189. /**
  70190. * Executes a function on change
  70191. * @param f A path cursor onchange callback
  70192. * @returns This path cursor
  70193. */
  70194. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70195. }
  70196. }
  70197. declare module BABYLON {
  70198. /** @hidden */
  70199. export var blurPixelShader: {
  70200. name: string;
  70201. shader: string;
  70202. };
  70203. }
  70204. declare module BABYLON {
  70205. /** @hidden */
  70206. export var pointCloudVertexDeclaration: {
  70207. name: string;
  70208. shader: string;
  70209. };
  70210. }
  70211. // Mixins
  70212. interface Window {
  70213. mozIndexedDB: IDBFactory;
  70214. webkitIndexedDB: IDBFactory;
  70215. msIndexedDB: IDBFactory;
  70216. webkitURL: typeof URL;
  70217. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70218. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70219. WebGLRenderingContext: WebGLRenderingContext;
  70220. MSGesture: MSGesture;
  70221. CANNON: any;
  70222. AudioContext: AudioContext;
  70223. webkitAudioContext: AudioContext;
  70224. PointerEvent: any;
  70225. Math: Math;
  70226. Uint8Array: Uint8ArrayConstructor;
  70227. Float32Array: Float32ArrayConstructor;
  70228. mozURL: typeof URL;
  70229. msURL: typeof URL;
  70230. VRFrameData: any; // WebVR, from specs 1.1
  70231. DracoDecoderModule: any;
  70232. setImmediate(handler: (...args: any[]) => void): number;
  70233. }
  70234. interface HTMLCanvasElement {
  70235. requestPointerLock(): void;
  70236. msRequestPointerLock?(): void;
  70237. mozRequestPointerLock?(): void;
  70238. webkitRequestPointerLock?(): void;
  70239. /** Track wether a record is in progress */
  70240. isRecording: boolean;
  70241. /** Capture Stream method defined by some browsers */
  70242. captureStream(fps?: number): MediaStream;
  70243. }
  70244. interface CanvasRenderingContext2D {
  70245. msImageSmoothingEnabled: boolean;
  70246. }
  70247. interface MouseEvent {
  70248. mozMovementX: number;
  70249. mozMovementY: number;
  70250. webkitMovementX: number;
  70251. webkitMovementY: number;
  70252. msMovementX: number;
  70253. msMovementY: number;
  70254. }
  70255. interface Navigator {
  70256. mozGetVRDevices: (any: any) => any;
  70257. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70258. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70259. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70260. webkitGetGamepads(): Gamepad[];
  70261. msGetGamepads(): Gamepad[];
  70262. webkitGamepads(): Gamepad[];
  70263. }
  70264. interface HTMLVideoElement {
  70265. mozSrcObject: any;
  70266. }
  70267. interface Math {
  70268. fround(x: number): number;
  70269. imul(a: number, b: number): number;
  70270. }
  70271. interface WebGLRenderingContext {
  70272. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70273. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70274. vertexAttribDivisor(index: number, divisor: number): void;
  70275. createVertexArray(): any;
  70276. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70277. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70278. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70279. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70280. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70281. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70282. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70283. // Queries
  70284. createQuery(): WebGLQuery;
  70285. deleteQuery(query: WebGLQuery): void;
  70286. beginQuery(target: number, query: WebGLQuery): void;
  70287. endQuery(target: number): void;
  70288. getQueryParameter(query: WebGLQuery, pname: number): any;
  70289. getQuery(target: number, pname: number): any;
  70290. MAX_SAMPLES: number;
  70291. RGBA8: number;
  70292. READ_FRAMEBUFFER: number;
  70293. DRAW_FRAMEBUFFER: number;
  70294. UNIFORM_BUFFER: number;
  70295. HALF_FLOAT_OES: number;
  70296. RGBA16F: number;
  70297. RGBA32F: number;
  70298. R32F: number;
  70299. RG32F: number;
  70300. RGB32F: number;
  70301. R16F: number;
  70302. RG16F: number;
  70303. RGB16F: number;
  70304. RED: number;
  70305. RG: number;
  70306. R8: number;
  70307. RG8: number;
  70308. UNSIGNED_INT_24_8: number;
  70309. DEPTH24_STENCIL8: number;
  70310. MIN: number;
  70311. MAX: number;
  70312. /* Multiple Render Targets */
  70313. drawBuffers(buffers: number[]): void;
  70314. readBuffer(src: number): void;
  70315. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70316. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70317. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70318. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70319. // Occlusion Query
  70320. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70321. ANY_SAMPLES_PASSED: number;
  70322. QUERY_RESULT_AVAILABLE: number;
  70323. QUERY_RESULT: number;
  70324. }
  70325. interface WebGLProgram {
  70326. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70327. }
  70328. interface EXT_disjoint_timer_query {
  70329. QUERY_COUNTER_BITS_EXT: number;
  70330. TIME_ELAPSED_EXT: number;
  70331. TIMESTAMP_EXT: number;
  70332. GPU_DISJOINT_EXT: number;
  70333. QUERY_RESULT_EXT: number;
  70334. QUERY_RESULT_AVAILABLE_EXT: number;
  70335. queryCounterEXT(query: WebGLQuery, target: number): void;
  70336. createQueryEXT(): WebGLQuery;
  70337. beginQueryEXT(target: number, query: WebGLQuery): void;
  70338. endQueryEXT(target: number): void;
  70339. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70340. deleteQueryEXT(query: WebGLQuery): void;
  70341. }
  70342. interface WebGLUniformLocation {
  70343. _currentState: any;
  70344. }
  70345. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70346. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70347. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70348. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70349. interface WebGLRenderingContext {
  70350. readonly RASTERIZER_DISCARD: number;
  70351. readonly DEPTH_COMPONENT24: number;
  70352. readonly TEXTURE_3D: number;
  70353. readonly TEXTURE_2D_ARRAY: number;
  70354. readonly TEXTURE_COMPARE_FUNC: number;
  70355. readonly TEXTURE_COMPARE_MODE: number;
  70356. readonly COMPARE_REF_TO_TEXTURE: number;
  70357. readonly TEXTURE_WRAP_R: number;
  70358. readonly HALF_FLOAT: number;
  70359. readonly RGB8: number;
  70360. readonly RED_INTEGER: number;
  70361. readonly RG_INTEGER: number;
  70362. readonly RGB_INTEGER: number;
  70363. readonly RGBA_INTEGER: number;
  70364. readonly R8_SNORM: number;
  70365. readonly RG8_SNORM: number;
  70366. readonly RGB8_SNORM: number;
  70367. readonly RGBA8_SNORM: number;
  70368. readonly R8I: number;
  70369. readonly RG8I: number;
  70370. readonly RGB8I: number;
  70371. readonly RGBA8I: number;
  70372. readonly R8UI: number;
  70373. readonly RG8UI: number;
  70374. readonly RGB8UI: number;
  70375. readonly RGBA8UI: number;
  70376. readonly R16I: number;
  70377. readonly RG16I: number;
  70378. readonly RGB16I: number;
  70379. readonly RGBA16I: number;
  70380. readonly R16UI: number;
  70381. readonly RG16UI: number;
  70382. readonly RGB16UI: number;
  70383. readonly RGBA16UI: number;
  70384. readonly R32I: number;
  70385. readonly RG32I: number;
  70386. readonly RGB32I: number;
  70387. readonly RGBA32I: number;
  70388. readonly R32UI: number;
  70389. readonly RG32UI: number;
  70390. readonly RGB32UI: number;
  70391. readonly RGBA32UI: number;
  70392. readonly RGB10_A2UI: number;
  70393. readonly R11F_G11F_B10F: number;
  70394. readonly RGB9_E5: number;
  70395. readonly RGB10_A2: number;
  70396. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70397. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70398. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70399. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70400. readonly DEPTH_COMPONENT32F: number;
  70401. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70402. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70403. 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;
  70404. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70405. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70406. readonly TRANSFORM_FEEDBACK: number;
  70407. readonly INTERLEAVED_ATTRIBS: number;
  70408. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70409. createTransformFeedback(): WebGLTransformFeedback;
  70410. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70411. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70412. beginTransformFeedback(primitiveMode: number): void;
  70413. endTransformFeedback(): void;
  70414. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70415. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70416. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70417. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70418. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70419. }
  70420. interface ImageBitmap {
  70421. readonly width: number;
  70422. readonly height: number;
  70423. close(): void;
  70424. }
  70425. interface WebGLQuery extends WebGLObject {
  70426. }
  70427. declare var WebGLQuery: {
  70428. prototype: WebGLQuery;
  70429. new(): WebGLQuery;
  70430. };
  70431. interface WebGLSampler extends WebGLObject {
  70432. }
  70433. declare var WebGLSampler: {
  70434. prototype: WebGLSampler;
  70435. new(): WebGLSampler;
  70436. };
  70437. interface WebGLSync extends WebGLObject {
  70438. }
  70439. declare var WebGLSync: {
  70440. prototype: WebGLSync;
  70441. new(): WebGLSync;
  70442. };
  70443. interface WebGLTransformFeedback extends WebGLObject {
  70444. }
  70445. declare var WebGLTransformFeedback: {
  70446. prototype: WebGLTransformFeedback;
  70447. new(): WebGLTransformFeedback;
  70448. };
  70449. interface WebGLVertexArrayObject extends WebGLObject {
  70450. }
  70451. declare var WebGLVertexArrayObject: {
  70452. prototype: WebGLVertexArrayObject;
  70453. new(): WebGLVertexArrayObject;
  70454. };
  70455. // Type definitions for WebVR API
  70456. // Project: https://w3c.github.io/webvr/
  70457. // Definitions by: six a <https://github.com/lostfictions>
  70458. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70459. interface VRDisplay extends EventTarget {
  70460. /**
  70461. * Dictionary of capabilities describing the VRDisplay.
  70462. */
  70463. readonly capabilities: VRDisplayCapabilities;
  70464. /**
  70465. * z-depth defining the far plane of the eye view frustum
  70466. * enables mapping of values in the render target depth
  70467. * attachment to scene coordinates. Initially set to 10000.0.
  70468. */
  70469. depthFar: number;
  70470. /**
  70471. * z-depth defining the near plane of the eye view frustum
  70472. * enables mapping of values in the render target depth
  70473. * attachment to scene coordinates. Initially set to 0.01.
  70474. */
  70475. depthNear: number;
  70476. /**
  70477. * An identifier for this distinct VRDisplay. Used as an
  70478. * association point in the Gamepad API.
  70479. */
  70480. readonly displayId: number;
  70481. /**
  70482. * A display name, a user-readable name identifying it.
  70483. */
  70484. readonly displayName: string;
  70485. readonly isConnected: boolean;
  70486. readonly isPresenting: boolean;
  70487. /**
  70488. * If this VRDisplay supports room-scale experiences, the optional
  70489. * stage attribute contains details on the room-scale parameters.
  70490. */
  70491. readonly stageParameters: VRStageParameters | null;
  70492. /**
  70493. * Passing the value returned by `requestAnimationFrame` to
  70494. * `cancelAnimationFrame` will unregister the callback.
  70495. * @param handle Define the hanle of the request to cancel
  70496. */
  70497. cancelAnimationFrame(handle: number): void;
  70498. /**
  70499. * Stops presenting to the VRDisplay.
  70500. * @returns a promise to know when it stopped
  70501. */
  70502. exitPresent(): Promise<void>;
  70503. /**
  70504. * Return the current VREyeParameters for the given eye.
  70505. * @param whichEye Define the eye we want the parameter for
  70506. * @returns the eye parameters
  70507. */
  70508. getEyeParameters(whichEye: string): VREyeParameters;
  70509. /**
  70510. * Populates the passed VRFrameData with the information required to render
  70511. * the current frame.
  70512. * @param frameData Define the data structure to populate
  70513. * @returns true if ok otherwise false
  70514. */
  70515. getFrameData(frameData: VRFrameData): boolean;
  70516. /**
  70517. * Get the layers currently being presented.
  70518. * @returns the list of VR layers
  70519. */
  70520. getLayers(): VRLayer[];
  70521. /**
  70522. * Return a VRPose containing the future predicted pose of the VRDisplay
  70523. * when the current frame will be presented. The value returned will not
  70524. * change until JavaScript has returned control to the browser.
  70525. *
  70526. * The VRPose will contain the position, orientation, velocity,
  70527. * and acceleration of each of these properties.
  70528. * @returns the pose object
  70529. */
  70530. getPose(): VRPose;
  70531. /**
  70532. * Return the current instantaneous pose of the VRDisplay, with no
  70533. * prediction applied.
  70534. * @returns the current instantaneous pose
  70535. */
  70536. getImmediatePose(): VRPose;
  70537. /**
  70538. * The callback passed to `requestAnimationFrame` will be called
  70539. * any time a new frame should be rendered. When the VRDisplay is
  70540. * presenting the callback will be called at the native refresh
  70541. * rate of the HMD. When not presenting this function acts
  70542. * identically to how window.requestAnimationFrame acts. Content should
  70543. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70544. * asynchronously from other displays and at differing refresh rates.
  70545. * @param callback Define the eaction to run next frame
  70546. * @returns the request handle it
  70547. */
  70548. requestAnimationFrame(callback: FrameRequestCallback): number;
  70549. /**
  70550. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70551. * Repeat calls while already presenting will update the VRLayers being displayed.
  70552. * @param layers Define the list of layer to present
  70553. * @returns a promise to know when the request has been fulfilled
  70554. */
  70555. requestPresent(layers: VRLayer[]): Promise<void>;
  70556. /**
  70557. * Reset the pose for this display, treating its current position and
  70558. * orientation as the "origin/zero" values. VRPose.position,
  70559. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70560. * updated when calling resetPose(). This should be called in only
  70561. * sitting-space experiences.
  70562. */
  70563. resetPose(): void;
  70564. /**
  70565. * The VRLayer provided to the VRDisplay will be captured and presented
  70566. * in the HMD. Calling this function has the same effect on the source
  70567. * canvas as any other operation that uses its source image, and canvases
  70568. * created without preserveDrawingBuffer set to true will be cleared.
  70569. * @param pose Define the pose to submit
  70570. */
  70571. submitFrame(pose?: VRPose): void;
  70572. }
  70573. declare var VRDisplay: {
  70574. prototype: VRDisplay;
  70575. new(): VRDisplay;
  70576. };
  70577. interface VRLayer {
  70578. leftBounds?: number[] | Float32Array | null;
  70579. rightBounds?: number[] | Float32Array | null;
  70580. source?: HTMLCanvasElement | null;
  70581. }
  70582. interface VRDisplayCapabilities {
  70583. readonly canPresent: boolean;
  70584. readonly hasExternalDisplay: boolean;
  70585. readonly hasOrientation: boolean;
  70586. readonly hasPosition: boolean;
  70587. readonly maxLayers: number;
  70588. }
  70589. interface VREyeParameters {
  70590. /** @deprecated */
  70591. readonly fieldOfView: VRFieldOfView;
  70592. readonly offset: Float32Array;
  70593. readonly renderHeight: number;
  70594. readonly renderWidth: number;
  70595. }
  70596. interface VRFieldOfView {
  70597. readonly downDegrees: number;
  70598. readonly leftDegrees: number;
  70599. readonly rightDegrees: number;
  70600. readonly upDegrees: number;
  70601. }
  70602. interface VRFrameData {
  70603. readonly leftProjectionMatrix: Float32Array;
  70604. readonly leftViewMatrix: Float32Array;
  70605. readonly pose: VRPose;
  70606. readonly rightProjectionMatrix: Float32Array;
  70607. readonly rightViewMatrix: Float32Array;
  70608. readonly timestamp: number;
  70609. }
  70610. interface VRPose {
  70611. readonly angularAcceleration: Float32Array | null;
  70612. readonly angularVelocity: Float32Array | null;
  70613. readonly linearAcceleration: Float32Array | null;
  70614. readonly linearVelocity: Float32Array | null;
  70615. readonly orientation: Float32Array | null;
  70616. readonly position: Float32Array | null;
  70617. readonly timestamp: number;
  70618. }
  70619. interface VRStageParameters {
  70620. sittingToStandingTransform?: Float32Array;
  70621. sizeX?: number;
  70622. sizeY?: number;
  70623. }
  70624. interface Navigator {
  70625. getVRDisplays(): Promise<VRDisplay[]>;
  70626. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70627. }
  70628. interface Window {
  70629. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70630. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70631. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70632. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70633. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70634. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70635. }
  70636. interface Gamepad {
  70637. readonly displayId: number;
  70638. }
  70639. type XRSessionMode =
  70640. | "inline"
  70641. | "immersive-vr"
  70642. | "immersive-ar";
  70643. type XRReferenceSpaceType =
  70644. | "viewer"
  70645. | "local"
  70646. | "local-floor"
  70647. | "bounded-floor"
  70648. | "unbounded";
  70649. type XREnvironmentBlendMode =
  70650. | "opaque"
  70651. | "additive"
  70652. | "alpha-blend";
  70653. type XRVisibilityState =
  70654. | "visible"
  70655. | "visible-blurred"
  70656. | "hidden";
  70657. type XRHandedness =
  70658. | "none"
  70659. | "left"
  70660. | "right";
  70661. type XRTargetRayMode =
  70662. | "gaze"
  70663. | "tracked-pointer"
  70664. | "screen";
  70665. type XREye =
  70666. | "none"
  70667. | "left"
  70668. | "right";
  70669. interface XRSpace extends EventTarget {
  70670. }
  70671. interface XRRenderState {
  70672. depthNear?: number;
  70673. depthFar?: number;
  70674. inlineVerticalFieldOfView?: number;
  70675. baseLayer?: XRWebGLLayer;
  70676. }
  70677. interface XRInputSource {
  70678. handedness: XRHandedness;
  70679. targetRayMode: XRTargetRayMode;
  70680. targetRaySpace: XRSpace;
  70681. gripSpace: XRSpace | undefined;
  70682. gamepad: Gamepad | undefined;
  70683. profiles: Array<string>;
  70684. }
  70685. interface XRSessionInit {
  70686. optionalFeatures?: XRReferenceSpaceType[];
  70687. requiredFeatures?: XRReferenceSpaceType[];
  70688. }
  70689. interface XRSession extends XRAnchorCreator {
  70690. addEventListener: Function;
  70691. removeEventListener: Function;
  70692. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70693. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70694. requestAnimationFrame: Function;
  70695. end(): Promise<void>;
  70696. renderState: XRRenderState;
  70697. inputSources: Array<XRInputSource>;
  70698. // hit test
  70699. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70700. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70701. // legacy AR hit test
  70702. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70703. // legacy plane detection
  70704. updateWorldTrackingState(options: {
  70705. planeDetectionState?: { enabled: boolean; }
  70706. }): void;
  70707. }
  70708. interface XRReferenceSpace extends XRSpace {
  70709. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70710. onreset: any;
  70711. }
  70712. type XRPlaneSet = Set<XRPlane>;
  70713. type XRAnchorSet = Set<XRAnchor>;
  70714. interface XRFrame {
  70715. session: XRSession;
  70716. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70717. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70718. // AR
  70719. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70720. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70721. // Anchors
  70722. trackedAnchors?: XRAnchorSet;
  70723. // Planes
  70724. worldInformation: {
  70725. detectedPlanes?: XRPlaneSet;
  70726. };
  70727. }
  70728. interface XRViewerPose extends XRPose {
  70729. views: Array<XRView>;
  70730. }
  70731. interface XRPose {
  70732. transform: XRRigidTransform;
  70733. emulatedPosition: boolean;
  70734. }
  70735. interface XRWebGLLayerOptions {
  70736. antialias?: boolean;
  70737. depth?: boolean;
  70738. stencil?: boolean;
  70739. alpha?: boolean;
  70740. multiview?: boolean;
  70741. framebufferScaleFactor?: number;
  70742. }
  70743. declare var XRWebGLLayer: {
  70744. prototype: XRWebGLLayer;
  70745. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70746. };
  70747. interface XRWebGLLayer {
  70748. framebuffer: WebGLFramebuffer;
  70749. framebufferWidth: number;
  70750. framebufferHeight: number;
  70751. getViewport: Function;
  70752. }
  70753. declare class XRRigidTransform {
  70754. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70755. position: DOMPointReadOnly;
  70756. orientation: DOMPointReadOnly;
  70757. matrix: Float32Array;
  70758. inverse: XRRigidTransform;
  70759. }
  70760. interface XRView {
  70761. eye: XREye;
  70762. projectionMatrix: Float32Array;
  70763. transform: XRRigidTransform;
  70764. }
  70765. interface XRInputSourceChangeEvent {
  70766. session: XRSession;
  70767. removed: Array<XRInputSource>;
  70768. added: Array<XRInputSource>;
  70769. }
  70770. interface XRInputSourceEvent extends Event {
  70771. readonly frame: XRFrame;
  70772. readonly inputSource: XRInputSource;
  70773. }
  70774. // Experimental(er) features
  70775. declare class XRRay {
  70776. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70777. origin: DOMPointReadOnly;
  70778. direction: DOMPointReadOnly;
  70779. matrix: Float32Array;
  70780. }
  70781. declare enum XRHitTestTrackableType {
  70782. "point",
  70783. "plane"
  70784. }
  70785. interface XRHitResult {
  70786. hitMatrix: Float32Array;
  70787. }
  70788. interface XRTransientInputHitTestResult {
  70789. readonly inputSource: XRInputSource;
  70790. readonly results: Array<XRHitTestResult>;
  70791. }
  70792. interface XRHitTestResult {
  70793. getPose(baseSpace: XRSpace): XRPose | undefined;
  70794. }
  70795. interface XRHitTestSource {
  70796. cancel(): void;
  70797. }
  70798. interface XRTransientInputHitTestSource {
  70799. cancel(): void;
  70800. }
  70801. interface XRHitTestOptionsInit {
  70802. space: XRSpace;
  70803. entityTypes?: Array<XRHitTestTrackableType>;
  70804. offsetRay?: XRRay;
  70805. }
  70806. interface XRTransientInputHitTestOptionsInit {
  70807. profile: string;
  70808. entityTypes?: Array<XRHitTestTrackableType>;
  70809. offsetRay?: XRRay;
  70810. }
  70811. interface XRAnchor {
  70812. // remove?
  70813. id?: string;
  70814. anchorSpace: XRSpace;
  70815. lastChangedTime: number;
  70816. detach(): void;
  70817. }
  70818. interface XRPlane extends XRAnchorCreator {
  70819. orientation: "Horizontal" | "Vertical";
  70820. planeSpace: XRSpace;
  70821. polygon: Array<DOMPointReadOnly>;
  70822. lastChangedTime: number;
  70823. }
  70824. interface XRAnchorCreator {
  70825. // AR Anchors
  70826. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70827. }
  70828. /**
  70829. * @ignore
  70830. */
  70831. declare module BABYLON.GLTF2.Exporter {
  70832. }
  70833. /**
  70834. * @ignore
  70835. */
  70836. declare module BABYLON.GLTF1 {
  70837. }
  70838. declare module BABYLON.GUI {
  70839. /**
  70840. * Class used to specific a value and its associated unit
  70841. */
  70842. export class ValueAndUnit {
  70843. /** defines the unit to store */
  70844. unit: number;
  70845. /** defines a boolean indicating if the value can be negative */
  70846. negativeValueAllowed: boolean;
  70847. private _value;
  70848. private _originalUnit;
  70849. /**
  70850. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70851. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70852. */
  70853. ignoreAdaptiveScaling: boolean;
  70854. /**
  70855. * Creates a new ValueAndUnit
  70856. * @param value defines the value to store
  70857. * @param unit defines the unit to store
  70858. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70859. */
  70860. constructor(value: number,
  70861. /** defines the unit to store */
  70862. unit?: number,
  70863. /** defines a boolean indicating if the value can be negative */
  70864. negativeValueAllowed?: boolean);
  70865. /** Gets a boolean indicating if the value is a percentage */
  70866. get isPercentage(): boolean;
  70867. /** Gets a boolean indicating if the value is store as pixel */
  70868. get isPixel(): boolean;
  70869. /** Gets direct internal value */
  70870. get internalValue(): number;
  70871. /**
  70872. * Gets value as pixel
  70873. * @param host defines the root host
  70874. * @param refValue defines the reference value for percentages
  70875. * @returns the value as pixel
  70876. */
  70877. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70878. /**
  70879. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70880. * @param value defines the value to store
  70881. * @param unit defines the unit to store
  70882. * @returns the current ValueAndUnit
  70883. */
  70884. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70885. /**
  70886. * Gets the value accordingly to its unit
  70887. * @param host defines the root host
  70888. * @returns the value
  70889. */
  70890. getValue(host: AdvancedDynamicTexture): number;
  70891. /**
  70892. * Gets a string representation of the value
  70893. * @param host defines the root host
  70894. * @param decimals defines an optional number of decimals to display
  70895. * @returns a string
  70896. */
  70897. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70898. /**
  70899. * Store a value parsed from a string
  70900. * @param source defines the source string
  70901. * @returns true if the value was successfully parsed
  70902. */
  70903. fromString(source: string | number): boolean;
  70904. private static _Regex;
  70905. private static _UNITMODE_PERCENTAGE;
  70906. private static _UNITMODE_PIXEL;
  70907. /** UNITMODE_PERCENTAGE */
  70908. static get UNITMODE_PERCENTAGE(): number;
  70909. /** UNITMODE_PIXEL */
  70910. static get UNITMODE_PIXEL(): number;
  70911. }
  70912. }
  70913. declare module BABYLON.GUI {
  70914. /**
  70915. * Define a style used by control to automatically setup properties based on a template.
  70916. * Only support font related properties so far
  70917. */
  70918. export class Style implements BABYLON.IDisposable {
  70919. private _fontFamily;
  70920. private _fontStyle;
  70921. private _fontWeight;
  70922. /** @hidden */
  70923. _host: AdvancedDynamicTexture;
  70924. /** @hidden */
  70925. _fontSize: ValueAndUnit;
  70926. /**
  70927. * BABYLON.Observable raised when the style values are changed
  70928. */
  70929. onChangedObservable: BABYLON.Observable<Style>;
  70930. /**
  70931. * Creates a new style object
  70932. * @param host defines the AdvancedDynamicTexture which hosts this style
  70933. */
  70934. constructor(host: AdvancedDynamicTexture);
  70935. /**
  70936. * Gets or sets the font size
  70937. */
  70938. get fontSize(): string | number;
  70939. set fontSize(value: string | number);
  70940. /**
  70941. * Gets or sets the font family
  70942. */
  70943. get fontFamily(): string;
  70944. set fontFamily(value: string);
  70945. /**
  70946. * Gets or sets the font style
  70947. */
  70948. get fontStyle(): string;
  70949. set fontStyle(value: string);
  70950. /** Gets or sets font weight */
  70951. get fontWeight(): string;
  70952. set fontWeight(value: string);
  70953. /** Dispose all associated resources */
  70954. dispose(): void;
  70955. }
  70956. }
  70957. declare module BABYLON.GUI {
  70958. /**
  70959. * Class used to transport BABYLON.Vector2 information for pointer events
  70960. */
  70961. export class Vector2WithInfo extends BABYLON.Vector2 {
  70962. /** defines the current mouse button index */
  70963. buttonIndex: number;
  70964. /**
  70965. * Creates a new Vector2WithInfo
  70966. * @param source defines the vector2 data to transport
  70967. * @param buttonIndex defines the current mouse button index
  70968. */
  70969. constructor(source: BABYLON.Vector2,
  70970. /** defines the current mouse button index */
  70971. buttonIndex?: number);
  70972. }
  70973. /** Class used to provide 2D matrix features */
  70974. export class Matrix2D {
  70975. /** Gets the internal array of 6 floats used to store matrix data */
  70976. m: Float32Array;
  70977. /**
  70978. * Creates a new matrix
  70979. * @param m00 defines value for (0, 0)
  70980. * @param m01 defines value for (0, 1)
  70981. * @param m10 defines value for (1, 0)
  70982. * @param m11 defines value for (1, 1)
  70983. * @param m20 defines value for (2, 0)
  70984. * @param m21 defines value for (2, 1)
  70985. */
  70986. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70987. /**
  70988. * Fills the matrix from direct values
  70989. * @param m00 defines value for (0, 0)
  70990. * @param m01 defines value for (0, 1)
  70991. * @param m10 defines value for (1, 0)
  70992. * @param m11 defines value for (1, 1)
  70993. * @param m20 defines value for (2, 0)
  70994. * @param m21 defines value for (2, 1)
  70995. * @returns the current modified matrix
  70996. */
  70997. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70998. /**
  70999. * Gets matrix determinant
  71000. * @returns the determinant
  71001. */
  71002. determinant(): number;
  71003. /**
  71004. * Inverses the matrix and stores it in a target matrix
  71005. * @param result defines the target matrix
  71006. * @returns the current matrix
  71007. */
  71008. invertToRef(result: Matrix2D): Matrix2D;
  71009. /**
  71010. * Multiplies the current matrix with another one
  71011. * @param other defines the second operand
  71012. * @param result defines the target matrix
  71013. * @returns the current matrix
  71014. */
  71015. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71016. /**
  71017. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71018. * @param x defines the x coordinate to transform
  71019. * @param y defines the x coordinate to transform
  71020. * @param result defines the target vector2
  71021. * @returns the current matrix
  71022. */
  71023. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71024. /**
  71025. * Creates an identity matrix
  71026. * @returns a new matrix
  71027. */
  71028. static Identity(): Matrix2D;
  71029. /**
  71030. * Creates a translation matrix and stores it in a target matrix
  71031. * @param x defines the x coordinate of the translation
  71032. * @param y defines the y coordinate of the translation
  71033. * @param result defines the target matrix
  71034. */
  71035. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71036. /**
  71037. * Creates a scaling matrix and stores it in a target matrix
  71038. * @param x defines the x coordinate of the scaling
  71039. * @param y defines the y coordinate of the scaling
  71040. * @param result defines the target matrix
  71041. */
  71042. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71043. /**
  71044. * Creates a rotation matrix and stores it in a target matrix
  71045. * @param angle defines the rotation angle
  71046. * @param result defines the target matrix
  71047. */
  71048. static RotationToRef(angle: number, result: Matrix2D): void;
  71049. private static _TempPreTranslationMatrix;
  71050. private static _TempPostTranslationMatrix;
  71051. private static _TempRotationMatrix;
  71052. private static _TempScalingMatrix;
  71053. private static _TempCompose0;
  71054. private static _TempCompose1;
  71055. private static _TempCompose2;
  71056. /**
  71057. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71058. * @param tx defines the x coordinate of the translation
  71059. * @param ty defines the y coordinate of the translation
  71060. * @param angle defines the rotation angle
  71061. * @param scaleX defines the x coordinate of the scaling
  71062. * @param scaleY defines the y coordinate of the scaling
  71063. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71064. * @param result defines the target matrix
  71065. */
  71066. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71067. }
  71068. }
  71069. declare module BABYLON.GUI {
  71070. /**
  71071. * Class used to store 2D control sizes
  71072. */
  71073. export class Measure {
  71074. /** defines left coordinate */
  71075. left: number;
  71076. /** defines top coordinate */
  71077. top: number;
  71078. /** defines width dimension */
  71079. width: number;
  71080. /** defines height dimension */
  71081. height: number;
  71082. /**
  71083. * Creates a new measure
  71084. * @param left defines left coordinate
  71085. * @param top defines top coordinate
  71086. * @param width defines width dimension
  71087. * @param height defines height dimension
  71088. */
  71089. constructor(
  71090. /** defines left coordinate */
  71091. left: number,
  71092. /** defines top coordinate */
  71093. top: number,
  71094. /** defines width dimension */
  71095. width: number,
  71096. /** defines height dimension */
  71097. height: number);
  71098. /**
  71099. * Copy from another measure
  71100. * @param other defines the other measure to copy from
  71101. */
  71102. copyFrom(other: Measure): void;
  71103. /**
  71104. * Copy from a group of 4 floats
  71105. * @param left defines left coordinate
  71106. * @param top defines top coordinate
  71107. * @param width defines width dimension
  71108. * @param height defines height dimension
  71109. */
  71110. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71111. /**
  71112. * Computes the axis aligned bounding box measure for two given measures
  71113. * @param a Input measure
  71114. * @param b Input measure
  71115. * @param result the resulting bounding measure
  71116. */
  71117. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71118. /**
  71119. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71120. * @param transform the matrix to transform the measure before computing the AABB
  71121. * @param result the resulting AABB
  71122. */
  71123. transformToRef(transform: Matrix2D, result: Measure): void;
  71124. /**
  71125. * Check equality between this measure and another one
  71126. * @param other defines the other measures
  71127. * @returns true if both measures are equals
  71128. */
  71129. isEqualsTo(other: Measure): boolean;
  71130. /**
  71131. * Creates an empty measure
  71132. * @returns a new measure
  71133. */
  71134. static Empty(): Measure;
  71135. }
  71136. }
  71137. declare module BABYLON.GUI {
  71138. /**
  71139. * Interface used to define a control that can receive focus
  71140. */
  71141. export interface IFocusableControl {
  71142. /**
  71143. * Function called when the control receives the focus
  71144. */
  71145. onFocus(): void;
  71146. /**
  71147. * Function called when the control loses the focus
  71148. */
  71149. onBlur(): void;
  71150. /**
  71151. * Function called to let the control handle keyboard events
  71152. * @param evt defines the current keyboard event
  71153. */
  71154. processKeyboard(evt: KeyboardEvent): void;
  71155. /**
  71156. * Function called to get the list of controls that should not steal the focus from this control
  71157. * @returns an array of controls
  71158. */
  71159. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71160. }
  71161. /**
  71162. * Class used to create texture to support 2D GUI elements
  71163. * @see http://doc.babylonjs.com/how_to/gui
  71164. */
  71165. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71166. private _isDirty;
  71167. private _renderObserver;
  71168. private _resizeObserver;
  71169. private _preKeyboardObserver;
  71170. private _pointerMoveObserver;
  71171. private _pointerObserver;
  71172. private _canvasPointerOutObserver;
  71173. private _background;
  71174. /** @hidden */
  71175. _rootContainer: Container;
  71176. /** @hidden */
  71177. _lastPickedControl: Control;
  71178. /** @hidden */
  71179. _lastControlOver: {
  71180. [pointerId: number]: Control;
  71181. };
  71182. /** @hidden */
  71183. _lastControlDown: {
  71184. [pointerId: number]: Control;
  71185. };
  71186. /** @hidden */
  71187. _capturingControl: {
  71188. [pointerId: number]: Control;
  71189. };
  71190. /** @hidden */
  71191. _shouldBlockPointer: boolean;
  71192. /** @hidden */
  71193. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71194. /** @hidden */
  71195. _linkedControls: Control[];
  71196. private _isFullscreen;
  71197. private _fullscreenViewport;
  71198. private _idealWidth;
  71199. private _idealHeight;
  71200. private _useSmallestIdeal;
  71201. private _renderAtIdealSize;
  71202. private _focusedControl;
  71203. private _blockNextFocusCheck;
  71204. private _renderScale;
  71205. private _rootElement;
  71206. private _cursorChanged;
  71207. private _defaultMousePointerId;
  71208. /** @hidden */
  71209. _numLayoutCalls: number;
  71210. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71211. get numLayoutCalls(): number;
  71212. /** @hidden */
  71213. _numRenderCalls: number;
  71214. /** Gets the number of render calls made the last time the ADT has been rendered */
  71215. get numRenderCalls(): number;
  71216. /**
  71217. * Define type to string to ensure compatibility across browsers
  71218. * Safari doesn't support DataTransfer constructor
  71219. */
  71220. private _clipboardData;
  71221. /**
  71222. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71223. */
  71224. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71225. /**
  71226. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71227. */
  71228. onControlPickedObservable: BABYLON.Observable<Control>;
  71229. /**
  71230. * BABYLON.Observable event triggered before layout is evaluated
  71231. */
  71232. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71233. /**
  71234. * BABYLON.Observable event triggered after the layout was evaluated
  71235. */
  71236. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71237. /**
  71238. * BABYLON.Observable event triggered before the texture is rendered
  71239. */
  71240. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71241. /**
  71242. * BABYLON.Observable event triggered after the texture was rendered
  71243. */
  71244. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71245. /**
  71246. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71247. */
  71248. premulAlpha: boolean;
  71249. /**
  71250. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71251. * Useful when you want more antialiasing
  71252. */
  71253. get renderScale(): number;
  71254. set renderScale(value: number);
  71255. /** Gets or sets the background color */
  71256. get background(): string;
  71257. set background(value: string);
  71258. /**
  71259. * Gets or sets the ideal width used to design controls.
  71260. * The GUI will then rescale everything accordingly
  71261. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71262. */
  71263. get idealWidth(): number;
  71264. set idealWidth(value: number);
  71265. /**
  71266. * Gets or sets the ideal height used to design controls.
  71267. * The GUI will then rescale everything accordingly
  71268. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71269. */
  71270. get idealHeight(): number;
  71271. set idealHeight(value: number);
  71272. /**
  71273. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71274. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71275. */
  71276. get useSmallestIdeal(): boolean;
  71277. set useSmallestIdeal(value: boolean);
  71278. /**
  71279. * Gets or sets a boolean indicating if adaptive scaling must be used
  71280. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71281. */
  71282. get renderAtIdealSize(): boolean;
  71283. set renderAtIdealSize(value: boolean);
  71284. /**
  71285. * Gets the ratio used when in "ideal mode"
  71286. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71287. * */
  71288. get idealRatio(): number;
  71289. /**
  71290. * Gets the underlying layer used to render the texture when in fullscreen mode
  71291. */
  71292. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71293. /**
  71294. * Gets the root container control
  71295. */
  71296. get rootContainer(): Container;
  71297. /**
  71298. * Returns an array containing the root container.
  71299. * This is mostly used to let the Inspector introspects the ADT
  71300. * @returns an array containing the rootContainer
  71301. */
  71302. getChildren(): Array<Container>;
  71303. /**
  71304. * Will return all controls that are inside this texture
  71305. * @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
  71306. * @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
  71307. * @return all child controls
  71308. */
  71309. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71310. /**
  71311. * Gets or sets the current focused control
  71312. */
  71313. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71314. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71315. /**
  71316. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71317. */
  71318. get isForeground(): boolean;
  71319. set isForeground(value: boolean);
  71320. /**
  71321. * Gets or set information about clipboardData
  71322. */
  71323. get clipboardData(): string;
  71324. set clipboardData(value: string);
  71325. /**
  71326. * Creates a new AdvancedDynamicTexture
  71327. * @param name defines the name of the texture
  71328. * @param width defines the width of the texture
  71329. * @param height defines the height of the texture
  71330. * @param scene defines the hosting scene
  71331. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71332. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71333. */
  71334. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71335. /**
  71336. * Get the current class name of the texture useful for serialization or dynamic coding.
  71337. * @returns "AdvancedDynamicTexture"
  71338. */
  71339. getClassName(): string;
  71340. /**
  71341. * Function used to execute a function on all controls
  71342. * @param func defines the function to execute
  71343. * @param container defines the container where controls belong. If null the root container will be used
  71344. */
  71345. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71346. private _useInvalidateRectOptimization;
  71347. /**
  71348. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71349. */
  71350. get useInvalidateRectOptimization(): boolean;
  71351. set useInvalidateRectOptimization(value: boolean);
  71352. private _invalidatedRectangle;
  71353. /**
  71354. * Invalidates a rectangle area on the gui texture
  71355. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71356. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71357. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71358. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71359. */
  71360. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71361. /**
  71362. * Marks the texture as dirty forcing a complete update
  71363. */
  71364. markAsDirty(): void;
  71365. /**
  71366. * Helper function used to create a new style
  71367. * @returns a new style
  71368. * @see http://doc.babylonjs.com/how_to/gui#styles
  71369. */
  71370. createStyle(): Style;
  71371. /**
  71372. * Adds a new control to the root container
  71373. * @param control defines the control to add
  71374. * @returns the current texture
  71375. */
  71376. addControl(control: Control): AdvancedDynamicTexture;
  71377. /**
  71378. * Removes a control from the root container
  71379. * @param control defines the control to remove
  71380. * @returns the current texture
  71381. */
  71382. removeControl(control: Control): AdvancedDynamicTexture;
  71383. /**
  71384. * Release all resources
  71385. */
  71386. dispose(): void;
  71387. private _onResize;
  71388. /** @hidden */
  71389. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71390. /**
  71391. * Get screen coordinates for a vector3
  71392. * @param position defines the position to project
  71393. * @param worldMatrix defines the world matrix to use
  71394. * @returns the projected position
  71395. */
  71396. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71397. private _checkUpdate;
  71398. private _clearMeasure;
  71399. private _render;
  71400. /** @hidden */
  71401. _changeCursor(cursor: string): void;
  71402. /** @hidden */
  71403. _registerLastControlDown(control: Control, pointerId: number): void;
  71404. private _doPicking;
  71405. /** @hidden */
  71406. _cleanControlAfterRemovalFromList(list: {
  71407. [pointerId: number]: Control;
  71408. }, control: Control): void;
  71409. /** @hidden */
  71410. _cleanControlAfterRemoval(control: Control): void;
  71411. /** Attach to all scene events required to support pointer events */
  71412. attach(): void;
  71413. /** @hidden */
  71414. private onClipboardCopy;
  71415. /** @hidden */
  71416. private onClipboardCut;
  71417. /** @hidden */
  71418. private onClipboardPaste;
  71419. /**
  71420. * Register the clipboard Events onto the canvas
  71421. */
  71422. registerClipboardEvents(): void;
  71423. /**
  71424. * Unregister the clipboard Events from the canvas
  71425. */
  71426. unRegisterClipboardEvents(): void;
  71427. /**
  71428. * Connect the texture to a hosting mesh to enable interactions
  71429. * @param mesh defines the mesh to attach to
  71430. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71431. */
  71432. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71433. /**
  71434. * Move the focus to a specific control
  71435. * @param control defines the control which will receive the focus
  71436. */
  71437. moveFocusToControl(control: IFocusableControl): void;
  71438. private _manageFocus;
  71439. private _attachToOnPointerOut;
  71440. /**
  71441. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71442. * @param mesh defines the mesh which will receive the texture
  71443. * @param width defines the texture width (1024 by default)
  71444. * @param height defines the texture height (1024 by default)
  71445. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71446. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71447. * @returns a new AdvancedDynamicTexture
  71448. */
  71449. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71450. /**
  71451. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71452. * In this mode the texture will rely on a layer for its rendering.
  71453. * This allows it to be treated like any other layer.
  71454. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71455. * LayerMask is set through advancedTexture.layer.layerMask
  71456. * @param name defines name for the texture
  71457. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71458. * @param scene defines the hsoting scene
  71459. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71460. * @returns a new AdvancedDynamicTexture
  71461. */
  71462. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71463. }
  71464. }
  71465. declare module BABYLON.GUI {
  71466. /**
  71467. * Root class used for all 2D controls
  71468. * @see http://doc.babylonjs.com/how_to/gui#controls
  71469. */
  71470. export class Control {
  71471. /** defines the name of the control */
  71472. name?: string | undefined;
  71473. /**
  71474. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71475. */
  71476. static AllowAlphaInheritance: boolean;
  71477. private _alpha;
  71478. private _alphaSet;
  71479. private _zIndex;
  71480. /** @hidden */
  71481. _host: AdvancedDynamicTexture;
  71482. /** Gets or sets the control parent */
  71483. parent: BABYLON.Nullable<Container>;
  71484. /** @hidden */
  71485. _currentMeasure: Measure;
  71486. private _fontFamily;
  71487. private _fontStyle;
  71488. private _fontWeight;
  71489. private _fontSize;
  71490. private _font;
  71491. /** @hidden */
  71492. _width: ValueAndUnit;
  71493. /** @hidden */
  71494. _height: ValueAndUnit;
  71495. /** @hidden */
  71496. protected _fontOffset: {
  71497. ascent: number;
  71498. height: number;
  71499. descent: number;
  71500. };
  71501. private _color;
  71502. private _style;
  71503. private _styleObserver;
  71504. /** @hidden */
  71505. protected _horizontalAlignment: number;
  71506. /** @hidden */
  71507. protected _verticalAlignment: number;
  71508. /** @hidden */
  71509. protected _isDirty: boolean;
  71510. /** @hidden */
  71511. protected _wasDirty: boolean;
  71512. /** @hidden */
  71513. _tempParentMeasure: Measure;
  71514. /** @hidden */
  71515. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71516. /** @hidden */
  71517. protected _cachedParentMeasure: Measure;
  71518. private _paddingLeft;
  71519. private _paddingRight;
  71520. private _paddingTop;
  71521. private _paddingBottom;
  71522. /** @hidden */
  71523. _left: ValueAndUnit;
  71524. /** @hidden */
  71525. _top: ValueAndUnit;
  71526. private _scaleX;
  71527. private _scaleY;
  71528. private _rotation;
  71529. private _transformCenterX;
  71530. private _transformCenterY;
  71531. /** @hidden */
  71532. _transformMatrix: Matrix2D;
  71533. /** @hidden */
  71534. protected _invertTransformMatrix: Matrix2D;
  71535. /** @hidden */
  71536. protected _transformedPosition: BABYLON.Vector2;
  71537. private _isMatrixDirty;
  71538. private _cachedOffsetX;
  71539. private _cachedOffsetY;
  71540. private _isVisible;
  71541. private _isHighlighted;
  71542. /** @hidden */
  71543. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71544. private _fontSet;
  71545. private _dummyVector2;
  71546. private _downCount;
  71547. private _enterCount;
  71548. private _doNotRender;
  71549. private _downPointerIds;
  71550. protected _isEnabled: boolean;
  71551. protected _disabledColor: string;
  71552. protected _disabledColorItem: string;
  71553. /** @hidden */
  71554. protected _rebuildLayout: boolean;
  71555. /** @hidden */
  71556. _customData: any;
  71557. /** @hidden */
  71558. _isClipped: boolean;
  71559. /** @hidden */
  71560. _automaticSize: boolean;
  71561. /** @hidden */
  71562. _tag: any;
  71563. /**
  71564. * 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
  71565. */
  71566. uniqueId: number;
  71567. /**
  71568. * Gets or sets an object used to store user defined information for the node
  71569. */
  71570. metadata: any;
  71571. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71572. isHitTestVisible: boolean;
  71573. /** Gets or sets a boolean indicating if the control can block pointer events */
  71574. isPointerBlocker: boolean;
  71575. /** Gets or sets a boolean indicating if the control can be focusable */
  71576. isFocusInvisible: boolean;
  71577. /**
  71578. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71579. * 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
  71580. */
  71581. clipChildren: boolean;
  71582. /**
  71583. * Gets or sets a boolean indicating that control content must be clipped
  71584. * 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
  71585. */
  71586. clipContent: boolean;
  71587. /**
  71588. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71589. */
  71590. useBitmapCache: boolean;
  71591. private _cacheData;
  71592. private _shadowOffsetX;
  71593. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71594. get shadowOffsetX(): number;
  71595. set shadowOffsetX(value: number);
  71596. private _shadowOffsetY;
  71597. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71598. get shadowOffsetY(): number;
  71599. set shadowOffsetY(value: number);
  71600. private _shadowBlur;
  71601. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71602. get shadowBlur(): number;
  71603. set shadowBlur(value: number);
  71604. private _shadowColor;
  71605. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71606. get shadowColor(): string;
  71607. set shadowColor(value: string);
  71608. /** Gets or sets the cursor to use when the control is hovered */
  71609. hoverCursor: string;
  71610. /** @hidden */
  71611. protected _linkOffsetX: ValueAndUnit;
  71612. /** @hidden */
  71613. protected _linkOffsetY: ValueAndUnit;
  71614. /** Gets the control type name */
  71615. get typeName(): string;
  71616. /**
  71617. * Get the current class name of the control.
  71618. * @returns current class name
  71619. */
  71620. getClassName(): string;
  71621. /**
  71622. * An event triggered when pointer wheel is scrolled
  71623. */
  71624. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71625. /**
  71626. * An event triggered when the pointer move over the control.
  71627. */
  71628. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71629. /**
  71630. * An event triggered when the pointer move out of the control.
  71631. */
  71632. onPointerOutObservable: BABYLON.Observable<Control>;
  71633. /**
  71634. * An event triggered when the pointer taps the control
  71635. */
  71636. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71637. /**
  71638. * An event triggered when pointer up
  71639. */
  71640. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71641. /**
  71642. * An event triggered when a control is clicked on
  71643. */
  71644. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71645. /**
  71646. * An event triggered when pointer enters the control
  71647. */
  71648. onPointerEnterObservable: BABYLON.Observable<Control>;
  71649. /**
  71650. * An event triggered when the control is marked as dirty
  71651. */
  71652. onDirtyObservable: BABYLON.Observable<Control>;
  71653. /**
  71654. * An event triggered before drawing the control
  71655. */
  71656. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71657. /**
  71658. * An event triggered after the control was drawn
  71659. */
  71660. onAfterDrawObservable: BABYLON.Observable<Control>;
  71661. /**
  71662. * Get the hosting AdvancedDynamicTexture
  71663. */
  71664. get host(): AdvancedDynamicTexture;
  71665. /** Gets or set information about font offsets (used to render and align text) */
  71666. get fontOffset(): {
  71667. ascent: number;
  71668. height: number;
  71669. descent: number;
  71670. };
  71671. set fontOffset(offset: {
  71672. ascent: number;
  71673. height: number;
  71674. descent: number;
  71675. });
  71676. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71677. get alpha(): number;
  71678. set alpha(value: number);
  71679. /**
  71680. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71681. */
  71682. get isHighlighted(): boolean;
  71683. set isHighlighted(value: boolean);
  71684. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71685. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71686. */
  71687. get scaleX(): number;
  71688. set scaleX(value: number);
  71689. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71690. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71691. */
  71692. get scaleY(): number;
  71693. set scaleY(value: number);
  71694. /** Gets or sets the rotation angle (0 by default)
  71695. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71696. */
  71697. get rotation(): number;
  71698. set rotation(value: number);
  71699. /** Gets or sets the transformation center on Y axis (0 by default)
  71700. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71701. */
  71702. get transformCenterY(): number;
  71703. set transformCenterY(value: number);
  71704. /** Gets or sets the transformation center on X axis (0 by default)
  71705. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71706. */
  71707. get transformCenterX(): number;
  71708. set transformCenterX(value: number);
  71709. /**
  71710. * Gets or sets the horizontal alignment
  71711. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71712. */
  71713. get horizontalAlignment(): number;
  71714. set horizontalAlignment(value: number);
  71715. /**
  71716. * Gets or sets the vertical alignment
  71717. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71718. */
  71719. get verticalAlignment(): number;
  71720. set verticalAlignment(value: number);
  71721. /**
  71722. * Gets or sets control width
  71723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71724. */
  71725. get width(): string | number;
  71726. set width(value: string | number);
  71727. /**
  71728. * Gets or sets the control width in pixel
  71729. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71730. */
  71731. get widthInPixels(): number;
  71732. set widthInPixels(value: number);
  71733. /**
  71734. * Gets or sets control height
  71735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71736. */
  71737. get height(): string | number;
  71738. set height(value: string | number);
  71739. /**
  71740. * Gets or sets control height in pixel
  71741. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71742. */
  71743. get heightInPixels(): number;
  71744. set heightInPixels(value: number);
  71745. /** Gets or set font family */
  71746. get fontFamily(): string;
  71747. set fontFamily(value: string);
  71748. /** Gets or sets font style */
  71749. get fontStyle(): string;
  71750. set fontStyle(value: string);
  71751. /** Gets or sets font weight */
  71752. get fontWeight(): string;
  71753. set fontWeight(value: string);
  71754. /**
  71755. * Gets or sets style
  71756. * @see http://doc.babylonjs.com/how_to/gui#styles
  71757. */
  71758. get style(): BABYLON.Nullable<Style>;
  71759. set style(value: BABYLON.Nullable<Style>);
  71760. /** @hidden */
  71761. get _isFontSizeInPercentage(): boolean;
  71762. /** Gets or sets font size in pixels */
  71763. get fontSizeInPixels(): number;
  71764. set fontSizeInPixels(value: number);
  71765. /** Gets or sets font size */
  71766. get fontSize(): string | number;
  71767. set fontSize(value: string | number);
  71768. /** Gets or sets foreground color */
  71769. get color(): string;
  71770. set color(value: string);
  71771. /** Gets or sets z index which is used to reorder controls on the z axis */
  71772. get zIndex(): number;
  71773. set zIndex(value: number);
  71774. /** Gets or sets a boolean indicating if the control can be rendered */
  71775. get notRenderable(): boolean;
  71776. set notRenderable(value: boolean);
  71777. /** Gets or sets a boolean indicating if the control is visible */
  71778. get isVisible(): boolean;
  71779. set isVisible(value: boolean);
  71780. /** Gets a boolean indicating that the control needs to update its rendering */
  71781. get isDirty(): boolean;
  71782. /**
  71783. * Gets the current linked mesh (or null if none)
  71784. */
  71785. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71786. /**
  71787. * Gets or sets a value indicating the padding to use on the left of the control
  71788. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71789. */
  71790. get paddingLeft(): string | number;
  71791. set paddingLeft(value: string | number);
  71792. /**
  71793. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71795. */
  71796. get paddingLeftInPixels(): number;
  71797. set paddingLeftInPixels(value: number);
  71798. /**
  71799. * Gets or sets a value indicating the padding to use on the right of the control
  71800. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71801. */
  71802. get paddingRight(): string | number;
  71803. set paddingRight(value: string | number);
  71804. /**
  71805. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71806. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71807. */
  71808. get paddingRightInPixels(): number;
  71809. set paddingRightInPixels(value: number);
  71810. /**
  71811. * Gets or sets a value indicating the padding to use on the top of the control
  71812. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71813. */
  71814. get paddingTop(): string | number;
  71815. set paddingTop(value: string | number);
  71816. /**
  71817. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71818. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71819. */
  71820. get paddingTopInPixels(): number;
  71821. set paddingTopInPixels(value: number);
  71822. /**
  71823. * Gets or sets a value indicating the padding to use on the bottom of the control
  71824. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71825. */
  71826. get paddingBottom(): string | number;
  71827. set paddingBottom(value: string | number);
  71828. /**
  71829. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71830. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71831. */
  71832. get paddingBottomInPixels(): number;
  71833. set paddingBottomInPixels(value: number);
  71834. /**
  71835. * Gets or sets a value indicating the left coordinate of the control
  71836. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71837. */
  71838. get left(): string | number;
  71839. set left(value: string | number);
  71840. /**
  71841. * Gets or sets a value indicating the left coordinate in pixels of the control
  71842. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71843. */
  71844. get leftInPixels(): number;
  71845. set leftInPixels(value: number);
  71846. /**
  71847. * Gets or sets a value indicating the top coordinate of the control
  71848. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71849. */
  71850. get top(): string | number;
  71851. set top(value: string | number);
  71852. /**
  71853. * Gets or sets a value indicating the top coordinate in pixels of the control
  71854. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71855. */
  71856. get topInPixels(): number;
  71857. set topInPixels(value: number);
  71858. /**
  71859. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71860. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71861. */
  71862. get linkOffsetX(): string | number;
  71863. set linkOffsetX(value: string | number);
  71864. /**
  71865. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71866. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71867. */
  71868. get linkOffsetXInPixels(): number;
  71869. set linkOffsetXInPixels(value: number);
  71870. /**
  71871. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71872. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71873. */
  71874. get linkOffsetY(): string | number;
  71875. set linkOffsetY(value: string | number);
  71876. /**
  71877. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71878. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71879. */
  71880. get linkOffsetYInPixels(): number;
  71881. set linkOffsetYInPixels(value: number);
  71882. /** Gets the center coordinate on X axis */
  71883. get centerX(): number;
  71884. /** Gets the center coordinate on Y axis */
  71885. get centerY(): number;
  71886. /** Gets or sets if control is Enabled*/
  71887. get isEnabled(): boolean;
  71888. set isEnabled(value: boolean);
  71889. /** Gets or sets background color of control if it's disabled*/
  71890. get disabledColor(): string;
  71891. set disabledColor(value: string);
  71892. /** Gets or sets front color of control if it's disabled*/
  71893. get disabledColorItem(): string;
  71894. set disabledColorItem(value: string);
  71895. /**
  71896. * Creates a new control
  71897. * @param name defines the name of the control
  71898. */
  71899. constructor(
  71900. /** defines the name of the control */
  71901. name?: string | undefined);
  71902. /** @hidden */
  71903. protected _getTypeName(): string;
  71904. /**
  71905. * Gets the first ascendant in the hierarchy of the given type
  71906. * @param className defines the required type
  71907. * @returns the ascendant or null if not found
  71908. */
  71909. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71910. /** @hidden */
  71911. _resetFontCache(): void;
  71912. /**
  71913. * Determines if a container is an ascendant of the current control
  71914. * @param container defines the container to look for
  71915. * @returns true if the container is one of the ascendant of the control
  71916. */
  71917. isAscendant(container: Control): boolean;
  71918. /**
  71919. * Gets coordinates in local control space
  71920. * @param globalCoordinates defines the coordinates to transform
  71921. * @returns the new coordinates in local space
  71922. */
  71923. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71924. /**
  71925. * Gets coordinates in local control space
  71926. * @param globalCoordinates defines the coordinates to transform
  71927. * @param result defines the target vector2 where to store the result
  71928. * @returns the current control
  71929. */
  71930. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71931. /**
  71932. * Gets coordinates in parent local control space
  71933. * @param globalCoordinates defines the coordinates to transform
  71934. * @returns the new coordinates in parent local space
  71935. */
  71936. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71937. /**
  71938. * Move the current control to a vector3 position projected onto the screen.
  71939. * @param position defines the target position
  71940. * @param scene defines the hosting scene
  71941. */
  71942. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71943. /**
  71944. * Will store all controls that have this control as ascendant in a given array
  71945. * @param results defines the array where to store the descendants
  71946. * @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
  71947. * @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
  71948. */
  71949. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71950. /**
  71951. * Will return all controls that have this control as ascendant
  71952. * @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
  71953. * @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
  71954. * @return all child controls
  71955. */
  71956. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71957. /**
  71958. * Link current control with a target mesh
  71959. * @param mesh defines the mesh to link with
  71960. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71961. */
  71962. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71963. /** @hidden */
  71964. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71965. /** @hidden */
  71966. _offsetLeft(offset: number): void;
  71967. /** @hidden */
  71968. _offsetTop(offset: number): void;
  71969. /** @hidden */
  71970. _markMatrixAsDirty(): void;
  71971. /** @hidden */
  71972. _flagDescendantsAsMatrixDirty(): void;
  71973. /** @hidden */
  71974. _intersectsRect(rect: Measure): boolean;
  71975. /** @hidden */
  71976. protected invalidateRect(): void;
  71977. /** @hidden */
  71978. _markAsDirty(force?: boolean): void;
  71979. /** @hidden */
  71980. _markAllAsDirty(): void;
  71981. /** @hidden */
  71982. _link(host: AdvancedDynamicTexture): void;
  71983. /** @hidden */
  71984. protected _transform(context?: CanvasRenderingContext2D): void;
  71985. /** @hidden */
  71986. _renderHighlight(context: CanvasRenderingContext2D): void;
  71987. /** @hidden */
  71988. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71989. /** @hidden */
  71990. protected _applyStates(context: CanvasRenderingContext2D): void;
  71991. /** @hidden */
  71992. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71993. /** @hidden */
  71994. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71995. protected _evaluateClippingState(parentMeasure: Measure): void;
  71996. /** @hidden */
  71997. _measure(): void;
  71998. /** @hidden */
  71999. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72000. /** @hidden */
  72001. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72002. /** @hidden */
  72003. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72004. /** @hidden */
  72005. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72006. private static _ClipMeasure;
  72007. private _tmpMeasureA;
  72008. private _clip;
  72009. /** @hidden */
  72010. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72011. /** @hidden */
  72012. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72013. /**
  72014. * Tests if a given coordinates belong to the current control
  72015. * @param x defines x coordinate to test
  72016. * @param y defines y coordinate to test
  72017. * @returns true if the coordinates are inside the control
  72018. */
  72019. contains(x: number, y: number): boolean;
  72020. /** @hidden */
  72021. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72022. /** @hidden */
  72023. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72024. /** @hidden */
  72025. _onPointerEnter(target: Control): boolean;
  72026. /** @hidden */
  72027. _onPointerOut(target: Control, force?: boolean): void;
  72028. /** @hidden */
  72029. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72030. /** @hidden */
  72031. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72032. /** @hidden */
  72033. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72034. /** @hidden */
  72035. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72036. /** @hidden */
  72037. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72038. private _prepareFont;
  72039. /** Releases associated resources */
  72040. dispose(): void;
  72041. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72042. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72043. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72044. private static _VERTICAL_ALIGNMENT_TOP;
  72045. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72046. private static _VERTICAL_ALIGNMENT_CENTER;
  72047. /** HORIZONTAL_ALIGNMENT_LEFT */
  72048. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72049. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72050. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72051. /** HORIZONTAL_ALIGNMENT_CENTER */
  72052. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72053. /** VERTICAL_ALIGNMENT_TOP */
  72054. static get VERTICAL_ALIGNMENT_TOP(): number;
  72055. /** VERTICAL_ALIGNMENT_BOTTOM */
  72056. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72057. /** VERTICAL_ALIGNMENT_CENTER */
  72058. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72059. private static _FontHeightSizes;
  72060. /** @hidden */
  72061. static _GetFontOffset(font: string): {
  72062. ascent: number;
  72063. height: number;
  72064. descent: number;
  72065. };
  72066. /**
  72067. * Creates a stack panel that can be used to render headers
  72068. * @param control defines the control to associate with the header
  72069. * @param text defines the text of the header
  72070. * @param size defines the size of the header
  72071. * @param options defines options used to configure the header
  72072. * @returns a new StackPanel
  72073. * @ignore
  72074. * @hidden
  72075. */
  72076. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72077. isHorizontal: boolean;
  72078. controlFirst: boolean;
  72079. }) => any;
  72080. /** @hidden */
  72081. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72082. }
  72083. }
  72084. declare module BABYLON.GUI {
  72085. /**
  72086. * Root class for 2D containers
  72087. * @see http://doc.babylonjs.com/how_to/gui#containers
  72088. */
  72089. export class Container extends Control {
  72090. name?: string | undefined;
  72091. /** @hidden */
  72092. _children: Control[];
  72093. /** @hidden */
  72094. protected _measureForChildren: Measure;
  72095. /** @hidden */
  72096. protected _background: string;
  72097. /** @hidden */
  72098. protected _adaptWidthToChildren: boolean;
  72099. /** @hidden */
  72100. protected _adaptHeightToChildren: boolean;
  72101. /**
  72102. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72103. */
  72104. logLayoutCycleErrors: boolean;
  72105. /**
  72106. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72107. */
  72108. maxLayoutCycle: number;
  72109. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72110. get adaptHeightToChildren(): boolean;
  72111. set adaptHeightToChildren(value: boolean);
  72112. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72113. get adaptWidthToChildren(): boolean;
  72114. set adaptWidthToChildren(value: boolean);
  72115. /** Gets or sets background color */
  72116. get background(): string;
  72117. set background(value: string);
  72118. /** Gets the list of children */
  72119. get children(): Control[];
  72120. /**
  72121. * Creates a new Container
  72122. * @param name defines the name of the container
  72123. */
  72124. constructor(name?: string | undefined);
  72125. protected _getTypeName(): string;
  72126. _flagDescendantsAsMatrixDirty(): void;
  72127. /**
  72128. * Gets a child using its name
  72129. * @param name defines the child name to look for
  72130. * @returns the child control if found
  72131. */
  72132. getChildByName(name: string): BABYLON.Nullable<Control>;
  72133. /**
  72134. * Gets a child using its type and its name
  72135. * @param name defines the child name to look for
  72136. * @param type defines the child type to look for
  72137. * @returns the child control if found
  72138. */
  72139. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72140. /**
  72141. * Search for a specific control in children
  72142. * @param control defines the control to look for
  72143. * @returns true if the control is in child list
  72144. */
  72145. containsControl(control: Control): boolean;
  72146. /**
  72147. * Adds a new control to the current container
  72148. * @param control defines the control to add
  72149. * @returns the current container
  72150. */
  72151. addControl(control: BABYLON.Nullable<Control>): Container;
  72152. /**
  72153. * Removes all controls from the current container
  72154. * @returns the current container
  72155. */
  72156. clearControls(): Container;
  72157. /**
  72158. * Removes a control from the current container
  72159. * @param control defines the control to remove
  72160. * @returns the current container
  72161. */
  72162. removeControl(control: Control): Container;
  72163. /** @hidden */
  72164. _reOrderControl(control: Control): void;
  72165. /** @hidden */
  72166. _offsetLeft(offset: number): void;
  72167. /** @hidden */
  72168. _offsetTop(offset: number): void;
  72169. /** @hidden */
  72170. _markAllAsDirty(): void;
  72171. /** @hidden */
  72172. protected _localDraw(context: CanvasRenderingContext2D): void;
  72173. /** @hidden */
  72174. _link(host: AdvancedDynamicTexture): void;
  72175. /** @hidden */
  72176. protected _beforeLayout(): void;
  72177. /** @hidden */
  72178. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72179. /** @hidden */
  72180. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72181. protected _postMeasure(): void;
  72182. /** @hidden */
  72183. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72184. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72185. /** @hidden */
  72186. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72187. /** @hidden */
  72188. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72189. /** Releases associated resources */
  72190. dispose(): void;
  72191. }
  72192. }
  72193. declare module BABYLON.GUI {
  72194. /** Class used to create rectangle container */
  72195. export class Rectangle extends Container {
  72196. name?: string | undefined;
  72197. private _thickness;
  72198. private _cornerRadius;
  72199. /** Gets or sets border thickness */
  72200. get thickness(): number;
  72201. set thickness(value: number);
  72202. /** Gets or sets the corner radius angle */
  72203. get cornerRadius(): number;
  72204. set cornerRadius(value: number);
  72205. /**
  72206. * Creates a new Rectangle
  72207. * @param name defines the control name
  72208. */
  72209. constructor(name?: string | undefined);
  72210. protected _getTypeName(): string;
  72211. protected _localDraw(context: CanvasRenderingContext2D): void;
  72212. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72213. private _drawRoundedRect;
  72214. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72215. }
  72216. }
  72217. declare module BABYLON.GUI {
  72218. /**
  72219. * Enum that determines the text-wrapping mode to use.
  72220. */
  72221. export enum TextWrapping {
  72222. /**
  72223. * Clip the text when it's larger than Control.width; this is the default mode.
  72224. */
  72225. Clip = 0,
  72226. /**
  72227. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72228. */
  72229. WordWrap = 1,
  72230. /**
  72231. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72232. */
  72233. Ellipsis = 2
  72234. }
  72235. /**
  72236. * Class used to create text block control
  72237. */
  72238. export class TextBlock extends Control {
  72239. /**
  72240. * Defines the name of the control
  72241. */
  72242. name?: string | undefined;
  72243. private _text;
  72244. private _textWrapping;
  72245. private _textHorizontalAlignment;
  72246. private _textVerticalAlignment;
  72247. private _lines;
  72248. private _resizeToFit;
  72249. private _lineSpacing;
  72250. private _outlineWidth;
  72251. private _outlineColor;
  72252. /**
  72253. * An event triggered after the text is changed
  72254. */
  72255. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72256. /**
  72257. * An event triggered after the text was broken up into lines
  72258. */
  72259. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72260. /**
  72261. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72262. */
  72263. get lines(): any[];
  72264. /**
  72265. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72266. */
  72267. get resizeToFit(): boolean;
  72268. /**
  72269. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72270. */
  72271. set resizeToFit(value: boolean);
  72272. /**
  72273. * Gets or sets a boolean indicating if text must be wrapped
  72274. */
  72275. get textWrapping(): TextWrapping | boolean;
  72276. /**
  72277. * Gets or sets a boolean indicating if text must be wrapped
  72278. */
  72279. set textWrapping(value: TextWrapping | boolean);
  72280. /**
  72281. * Gets or sets text to display
  72282. */
  72283. get text(): string;
  72284. /**
  72285. * Gets or sets text to display
  72286. */
  72287. set text(value: string);
  72288. /**
  72289. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72290. */
  72291. get textHorizontalAlignment(): number;
  72292. /**
  72293. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72294. */
  72295. set textHorizontalAlignment(value: number);
  72296. /**
  72297. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72298. */
  72299. get textVerticalAlignment(): number;
  72300. /**
  72301. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72302. */
  72303. set textVerticalAlignment(value: number);
  72304. /**
  72305. * Gets or sets line spacing value
  72306. */
  72307. set lineSpacing(value: string | number);
  72308. /**
  72309. * Gets or sets line spacing value
  72310. */
  72311. get lineSpacing(): string | number;
  72312. /**
  72313. * Gets or sets outlineWidth of the text to display
  72314. */
  72315. get outlineWidth(): number;
  72316. /**
  72317. * Gets or sets outlineWidth of the text to display
  72318. */
  72319. set outlineWidth(value: number);
  72320. /**
  72321. * Gets or sets outlineColor of the text to display
  72322. */
  72323. get outlineColor(): string;
  72324. /**
  72325. * Gets or sets outlineColor of the text to display
  72326. */
  72327. set outlineColor(value: string);
  72328. /**
  72329. * Creates a new TextBlock object
  72330. * @param name defines the name of the control
  72331. * @param text defines the text to display (emptry string by default)
  72332. */
  72333. constructor(
  72334. /**
  72335. * Defines the name of the control
  72336. */
  72337. name?: string | undefined, text?: string);
  72338. protected _getTypeName(): string;
  72339. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72340. private _drawText;
  72341. /** @hidden */
  72342. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72343. protected _applyStates(context: CanvasRenderingContext2D): void;
  72344. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72345. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72346. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72347. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72348. protected _renderLines(context: CanvasRenderingContext2D): void;
  72349. /**
  72350. * Given a width constraint applied on the text block, find the expected height
  72351. * @returns expected height
  72352. */
  72353. computeExpectedHeight(): number;
  72354. dispose(): void;
  72355. }
  72356. }
  72357. declare module BABYLON.GUI {
  72358. /**
  72359. * Class used to create 2D images
  72360. */
  72361. export class Image extends Control {
  72362. name?: string | undefined;
  72363. private _workingCanvas;
  72364. private _domImage;
  72365. private _imageWidth;
  72366. private _imageHeight;
  72367. private _loaded;
  72368. private _stretch;
  72369. private _source;
  72370. private _autoScale;
  72371. private _sourceLeft;
  72372. private _sourceTop;
  72373. private _sourceWidth;
  72374. private _sourceHeight;
  72375. private _svgAttributesComputationCompleted;
  72376. private _isSVG;
  72377. private _cellWidth;
  72378. private _cellHeight;
  72379. private _cellId;
  72380. private _populateNinePatchSlicesFromImage;
  72381. private _sliceLeft;
  72382. private _sliceRight;
  72383. private _sliceTop;
  72384. private _sliceBottom;
  72385. private _detectPointerOnOpaqueOnly;
  72386. /**
  72387. * BABYLON.Observable notified when the content is loaded
  72388. */
  72389. onImageLoadedObservable: BABYLON.Observable<Image>;
  72390. /**
  72391. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72392. */
  72393. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72394. /**
  72395. * Gets a boolean indicating that the content is loaded
  72396. */
  72397. get isLoaded(): boolean;
  72398. /**
  72399. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72400. */
  72401. get populateNinePatchSlicesFromImage(): boolean;
  72402. set populateNinePatchSlicesFromImage(value: boolean);
  72403. /**
  72404. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72405. * Beware using this as this will comsume more memory as the image has to be stored twice
  72406. */
  72407. get detectPointerOnOpaqueOnly(): boolean;
  72408. set detectPointerOnOpaqueOnly(value: boolean);
  72409. /**
  72410. * Gets or sets the left value for slicing (9-patch)
  72411. */
  72412. get sliceLeft(): number;
  72413. set sliceLeft(value: number);
  72414. /**
  72415. * Gets or sets the right value for slicing (9-patch)
  72416. */
  72417. get sliceRight(): number;
  72418. set sliceRight(value: number);
  72419. /**
  72420. * Gets or sets the top value for slicing (9-patch)
  72421. */
  72422. get sliceTop(): number;
  72423. set sliceTop(value: number);
  72424. /**
  72425. * Gets or sets the bottom value for slicing (9-patch)
  72426. */
  72427. get sliceBottom(): number;
  72428. set sliceBottom(value: number);
  72429. /**
  72430. * Gets or sets the left coordinate in the source image
  72431. */
  72432. get sourceLeft(): number;
  72433. set sourceLeft(value: number);
  72434. /**
  72435. * Gets or sets the top coordinate in the source image
  72436. */
  72437. get sourceTop(): number;
  72438. set sourceTop(value: number);
  72439. /**
  72440. * Gets or sets the width to capture in the source image
  72441. */
  72442. get sourceWidth(): number;
  72443. set sourceWidth(value: number);
  72444. /**
  72445. * Gets or sets the height to capture in the source image
  72446. */
  72447. get sourceHeight(): number;
  72448. set sourceHeight(value: number);
  72449. /** Indicates if the format of the image is SVG */
  72450. get isSVG(): boolean;
  72451. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72452. get svgAttributesComputationCompleted(): boolean;
  72453. /**
  72454. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72455. * @see http://doc.babylonjs.com/how_to/gui#image
  72456. */
  72457. get autoScale(): boolean;
  72458. set autoScale(value: boolean);
  72459. /** Gets or sets the streching mode used by the image */
  72460. get stretch(): number;
  72461. set stretch(value: number);
  72462. /** @hidden */
  72463. _rotate90(n: number, preserveProperties?: boolean): Image;
  72464. private _handleRotationForSVGImage;
  72465. private _rotate90SourceProperties;
  72466. /**
  72467. * Gets or sets the internal DOM image used to render the control
  72468. */
  72469. set domImage(value: HTMLImageElement);
  72470. get domImage(): HTMLImageElement;
  72471. private _onImageLoaded;
  72472. private _extractNinePatchSliceDataFromImage;
  72473. /**
  72474. * Gets or sets image source url
  72475. */
  72476. set source(value: BABYLON.Nullable<string>);
  72477. /**
  72478. * Checks for svg document with icon id present
  72479. */
  72480. private _svgCheck;
  72481. /**
  72482. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72483. * given external svg file and icon id
  72484. */
  72485. private _getSVGAttribs;
  72486. /**
  72487. * Gets or sets the cell width to use when animation sheet is enabled
  72488. * @see http://doc.babylonjs.com/how_to/gui#image
  72489. */
  72490. get cellWidth(): number;
  72491. set cellWidth(value: number);
  72492. /**
  72493. * Gets or sets the cell height to use when animation sheet is enabled
  72494. * @see http://doc.babylonjs.com/how_to/gui#image
  72495. */
  72496. get cellHeight(): number;
  72497. set cellHeight(value: number);
  72498. /**
  72499. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72500. * @see http://doc.babylonjs.com/how_to/gui#image
  72501. */
  72502. get cellId(): number;
  72503. set cellId(value: number);
  72504. /**
  72505. * Creates a new Image
  72506. * @param name defines the control name
  72507. * @param url defines the image url
  72508. */
  72509. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72510. /**
  72511. * Tests if a given coordinates belong to the current control
  72512. * @param x defines x coordinate to test
  72513. * @param y defines y coordinate to test
  72514. * @returns true if the coordinates are inside the control
  72515. */
  72516. contains(x: number, y: number): boolean;
  72517. protected _getTypeName(): string;
  72518. /** Force the control to synchronize with its content */
  72519. synchronizeSizeWithContent(): void;
  72520. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72521. private _prepareWorkingCanvasForOpaqueDetection;
  72522. private _drawImage;
  72523. _draw(context: CanvasRenderingContext2D): void;
  72524. private _renderCornerPatch;
  72525. private _renderNinePatch;
  72526. dispose(): void;
  72527. /** STRETCH_NONE */
  72528. static readonly STRETCH_NONE: number;
  72529. /** STRETCH_FILL */
  72530. static readonly STRETCH_FILL: number;
  72531. /** STRETCH_UNIFORM */
  72532. static readonly STRETCH_UNIFORM: number;
  72533. /** STRETCH_EXTEND */
  72534. static readonly STRETCH_EXTEND: number;
  72535. /** NINE_PATCH */
  72536. static readonly STRETCH_NINE_PATCH: number;
  72537. }
  72538. }
  72539. declare module BABYLON.GUI {
  72540. /**
  72541. * Class used to create 2D buttons
  72542. */
  72543. export class Button extends Rectangle {
  72544. name?: string | undefined;
  72545. /**
  72546. * Function called to generate a pointer enter animation
  72547. */
  72548. pointerEnterAnimation: () => void;
  72549. /**
  72550. * Function called to generate a pointer out animation
  72551. */
  72552. pointerOutAnimation: () => void;
  72553. /**
  72554. * Function called to generate a pointer down animation
  72555. */
  72556. pointerDownAnimation: () => void;
  72557. /**
  72558. * Function called to generate a pointer up animation
  72559. */
  72560. pointerUpAnimation: () => void;
  72561. /**
  72562. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72563. */
  72564. delegatePickingToChildren: boolean;
  72565. private _image;
  72566. /**
  72567. * Returns the image part of the button (if any)
  72568. */
  72569. get image(): BABYLON.Nullable<Image>;
  72570. private _textBlock;
  72571. /**
  72572. * Returns the image part of the button (if any)
  72573. */
  72574. get textBlock(): BABYLON.Nullable<TextBlock>;
  72575. /**
  72576. * Creates a new Button
  72577. * @param name defines the name of the button
  72578. */
  72579. constructor(name?: string | undefined);
  72580. protected _getTypeName(): string;
  72581. /** @hidden */
  72582. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72583. /** @hidden */
  72584. _onPointerEnter(target: Control): boolean;
  72585. /** @hidden */
  72586. _onPointerOut(target: Control, force?: boolean): void;
  72587. /** @hidden */
  72588. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72589. /** @hidden */
  72590. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72591. /**
  72592. * Creates a new button made with an image and a text
  72593. * @param name defines the name of the button
  72594. * @param text defines the text of the button
  72595. * @param imageUrl defines the url of the image
  72596. * @returns a new Button
  72597. */
  72598. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72599. /**
  72600. * Creates a new button made with an image
  72601. * @param name defines the name of the button
  72602. * @param imageUrl defines the url of the image
  72603. * @returns a new Button
  72604. */
  72605. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72606. /**
  72607. * Creates a new button made with a text
  72608. * @param name defines the name of the button
  72609. * @param text defines the text of the button
  72610. * @returns a new Button
  72611. */
  72612. static CreateSimpleButton(name: string, text: string): Button;
  72613. /**
  72614. * Creates a new button made with an image and a centered text
  72615. * @param name defines the name of the button
  72616. * @param text defines the text of the button
  72617. * @param imageUrl defines the url of the image
  72618. * @returns a new Button
  72619. */
  72620. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72621. }
  72622. }
  72623. declare module BABYLON.GUI {
  72624. /**
  72625. * Class used to create a 2D stack panel container
  72626. */
  72627. export class StackPanel extends Container {
  72628. name?: string | undefined;
  72629. private _isVertical;
  72630. private _manualWidth;
  72631. private _manualHeight;
  72632. private _doNotTrackManualChanges;
  72633. /**
  72634. * Gets or sets a boolean indicating that layou warnings should be ignored
  72635. */
  72636. ignoreLayoutWarnings: boolean;
  72637. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72638. get isVertical(): boolean;
  72639. set isVertical(value: boolean);
  72640. /**
  72641. * Gets or sets panel width.
  72642. * This value should not be set when in horizontal mode as it will be computed automatically
  72643. */
  72644. set width(value: string | number);
  72645. get width(): string | number;
  72646. /**
  72647. * Gets or sets panel height.
  72648. * This value should not be set when in vertical mode as it will be computed automatically
  72649. */
  72650. set height(value: string | number);
  72651. get height(): string | number;
  72652. /**
  72653. * Creates a new StackPanel
  72654. * @param name defines control name
  72655. */
  72656. constructor(name?: string | undefined);
  72657. protected _getTypeName(): string;
  72658. /** @hidden */
  72659. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72660. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72661. protected _postMeasure(): void;
  72662. }
  72663. }
  72664. declare module BABYLON.GUI {
  72665. /**
  72666. * Class used to represent a 2D checkbox
  72667. */
  72668. export class Checkbox extends Control {
  72669. name?: string | undefined;
  72670. private _isChecked;
  72671. private _background;
  72672. private _checkSizeRatio;
  72673. private _thickness;
  72674. /** Gets or sets border thickness */
  72675. get thickness(): number;
  72676. set thickness(value: number);
  72677. /**
  72678. * BABYLON.Observable raised when isChecked property changes
  72679. */
  72680. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72681. /** Gets or sets a value indicating the ratio between overall size and check size */
  72682. get checkSizeRatio(): number;
  72683. set checkSizeRatio(value: number);
  72684. /** Gets or sets background color */
  72685. get background(): string;
  72686. set background(value: string);
  72687. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72688. get isChecked(): boolean;
  72689. set isChecked(value: boolean);
  72690. /**
  72691. * Creates a new CheckBox
  72692. * @param name defines the control name
  72693. */
  72694. constructor(name?: string | undefined);
  72695. protected _getTypeName(): string;
  72696. /** @hidden */
  72697. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72698. /** @hidden */
  72699. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72700. /**
  72701. * Utility function to easily create a checkbox with a header
  72702. * @param title defines the label to use for the header
  72703. * @param onValueChanged defines the callback to call when value changes
  72704. * @returns a StackPanel containing the checkbox and a textBlock
  72705. */
  72706. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72707. }
  72708. }
  72709. declare module BABYLON.GUI {
  72710. /**
  72711. * Class used to store key control properties
  72712. */
  72713. export class KeyPropertySet {
  72714. /** Width */
  72715. width?: string;
  72716. /** Height */
  72717. height?: string;
  72718. /** Left padding */
  72719. paddingLeft?: string;
  72720. /** Right padding */
  72721. paddingRight?: string;
  72722. /** Top padding */
  72723. paddingTop?: string;
  72724. /** Bottom padding */
  72725. paddingBottom?: string;
  72726. /** Foreground color */
  72727. color?: string;
  72728. /** Background color */
  72729. background?: string;
  72730. }
  72731. /**
  72732. * Class used to create virtual keyboard
  72733. */
  72734. export class VirtualKeyboard extends StackPanel {
  72735. /** BABYLON.Observable raised when a key is pressed */
  72736. onKeyPressObservable: BABYLON.Observable<string>;
  72737. /** Gets or sets default key button width */
  72738. defaultButtonWidth: string;
  72739. /** Gets or sets default key button height */
  72740. defaultButtonHeight: string;
  72741. /** Gets or sets default key button left padding */
  72742. defaultButtonPaddingLeft: string;
  72743. /** Gets or sets default key button right padding */
  72744. defaultButtonPaddingRight: string;
  72745. /** Gets or sets default key button top padding */
  72746. defaultButtonPaddingTop: string;
  72747. /** Gets or sets default key button bottom padding */
  72748. defaultButtonPaddingBottom: string;
  72749. /** Gets or sets default key button foreground color */
  72750. defaultButtonColor: string;
  72751. /** Gets or sets default key button background color */
  72752. defaultButtonBackground: string;
  72753. /** Gets or sets shift button foreground color */
  72754. shiftButtonColor: string;
  72755. /** Gets or sets shift button thickness*/
  72756. selectedShiftThickness: number;
  72757. /** Gets shift key state */
  72758. shiftState: number;
  72759. protected _getTypeName(): string;
  72760. private _createKey;
  72761. /**
  72762. * Adds a new row of keys
  72763. * @param keys defines the list of keys to add
  72764. * @param propertySets defines the associated property sets
  72765. */
  72766. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72767. /**
  72768. * Set the shift key to a specific state
  72769. * @param shiftState defines the new shift state
  72770. */
  72771. applyShiftState(shiftState: number): void;
  72772. private _currentlyConnectedInputText;
  72773. private _connectedInputTexts;
  72774. private _onKeyPressObserver;
  72775. /** Gets the input text control currently attached to the keyboard */
  72776. get connectedInputText(): BABYLON.Nullable<InputText>;
  72777. /**
  72778. * Connects the keyboard with an input text control
  72779. *
  72780. * @param input defines the target control
  72781. */
  72782. connect(input: InputText): void;
  72783. /**
  72784. * Disconnects the keyboard from connected InputText controls
  72785. *
  72786. * @param input optionally defines a target control, otherwise all are disconnected
  72787. */
  72788. disconnect(input?: InputText): void;
  72789. private _removeConnectedInputObservables;
  72790. /**
  72791. * Release all resources
  72792. */
  72793. dispose(): void;
  72794. /**
  72795. * Creates a new keyboard using a default layout
  72796. *
  72797. * @param name defines control name
  72798. * @returns a new VirtualKeyboard
  72799. */
  72800. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72801. }
  72802. }
  72803. declare module BABYLON.GUI {
  72804. /**
  72805. * Class used to create input text control
  72806. */
  72807. export class InputText extends Control implements IFocusableControl {
  72808. name?: string | undefined;
  72809. private _text;
  72810. private _placeholderText;
  72811. private _background;
  72812. private _focusedBackground;
  72813. private _focusedColor;
  72814. private _placeholderColor;
  72815. private _thickness;
  72816. private _margin;
  72817. private _autoStretchWidth;
  72818. private _maxWidth;
  72819. private _isFocused;
  72820. private _blinkTimeout;
  72821. private _blinkIsEven;
  72822. private _cursorOffset;
  72823. private _scrollLeft;
  72824. private _textWidth;
  72825. private _clickedCoordinate;
  72826. private _deadKey;
  72827. private _addKey;
  72828. private _currentKey;
  72829. private _isTextHighlightOn;
  72830. private _textHighlightColor;
  72831. private _highligherOpacity;
  72832. private _highlightedText;
  72833. private _startHighlightIndex;
  72834. private _endHighlightIndex;
  72835. private _cursorIndex;
  72836. private _onFocusSelectAll;
  72837. private _isPointerDown;
  72838. private _onClipboardObserver;
  72839. private _onPointerDblTapObserver;
  72840. /** @hidden */
  72841. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72842. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72843. promptMessage: string;
  72844. /** Force disable prompt on mobile device */
  72845. disableMobilePrompt: boolean;
  72846. /** BABYLON.Observable raised when the text changes */
  72847. onTextChangedObservable: BABYLON.Observable<InputText>;
  72848. /** BABYLON.Observable raised just before an entered character is to be added */
  72849. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72850. /** BABYLON.Observable raised when the control gets the focus */
  72851. onFocusObservable: BABYLON.Observable<InputText>;
  72852. /** BABYLON.Observable raised when the control loses the focus */
  72853. onBlurObservable: BABYLON.Observable<InputText>;
  72854. /**Observable raised when the text is highlighted */
  72855. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72856. /**Observable raised when copy event is triggered */
  72857. onTextCopyObservable: BABYLON.Observable<InputText>;
  72858. /** BABYLON.Observable raised when cut event is triggered */
  72859. onTextCutObservable: BABYLON.Observable<InputText>;
  72860. /** BABYLON.Observable raised when paste event is triggered */
  72861. onTextPasteObservable: BABYLON.Observable<InputText>;
  72862. /** BABYLON.Observable raised when a key event was processed */
  72863. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72864. /** Gets or sets the maximum width allowed by the control */
  72865. get maxWidth(): string | number;
  72866. /** Gets the maximum width allowed by the control in pixels */
  72867. get maxWidthInPixels(): number;
  72868. set maxWidth(value: string | number);
  72869. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72870. get highligherOpacity(): number;
  72871. set highligherOpacity(value: number);
  72872. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72873. get onFocusSelectAll(): boolean;
  72874. set onFocusSelectAll(value: boolean);
  72875. /** Gets or sets the text hightlight color */
  72876. get textHighlightColor(): string;
  72877. set textHighlightColor(value: string);
  72878. /** Gets or sets control margin */
  72879. get margin(): string;
  72880. /** Gets control margin in pixels */
  72881. get marginInPixels(): number;
  72882. set margin(value: string);
  72883. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72884. get autoStretchWidth(): boolean;
  72885. set autoStretchWidth(value: boolean);
  72886. /** Gets or sets border thickness */
  72887. get thickness(): number;
  72888. set thickness(value: number);
  72889. /** Gets or sets the background color when focused */
  72890. get focusedBackground(): string;
  72891. set focusedBackground(value: string);
  72892. /** Gets or sets the background color when focused */
  72893. get focusedColor(): string;
  72894. set focusedColor(value: string);
  72895. /** Gets or sets the background color */
  72896. get background(): string;
  72897. set background(value: string);
  72898. /** Gets or sets the placeholder color */
  72899. get placeholderColor(): string;
  72900. set placeholderColor(value: string);
  72901. /** Gets or sets the text displayed when the control is empty */
  72902. get placeholderText(): string;
  72903. set placeholderText(value: string);
  72904. /** Gets or sets the dead key flag */
  72905. get deadKey(): boolean;
  72906. set deadKey(flag: boolean);
  72907. /** Gets or sets the highlight text */
  72908. get highlightedText(): string;
  72909. set highlightedText(text: string);
  72910. /** Gets or sets if the current key should be added */
  72911. get addKey(): boolean;
  72912. set addKey(flag: boolean);
  72913. /** Gets or sets the value of the current key being entered */
  72914. get currentKey(): string;
  72915. set currentKey(key: string);
  72916. /** Gets or sets the text displayed in the control */
  72917. get text(): string;
  72918. set text(value: string);
  72919. /** Gets or sets control width */
  72920. get width(): string | number;
  72921. set width(value: string | number);
  72922. /**
  72923. * Creates a new InputText
  72924. * @param name defines the control name
  72925. * @param text defines the text of the control
  72926. */
  72927. constructor(name?: string | undefined, text?: string);
  72928. /** @hidden */
  72929. onBlur(): void;
  72930. /** @hidden */
  72931. onFocus(): void;
  72932. protected _getTypeName(): string;
  72933. /**
  72934. * Function called to get the list of controls that should not steal the focus from this control
  72935. * @returns an array of controls
  72936. */
  72937. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72938. /** @hidden */
  72939. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72940. /** @hidden */
  72941. private _updateValueFromCursorIndex;
  72942. /** @hidden */
  72943. private _processDblClick;
  72944. /** @hidden */
  72945. private _selectAllText;
  72946. /**
  72947. * Handles the keyboard event
  72948. * @param evt Defines the KeyboardEvent
  72949. */
  72950. processKeyboard(evt: KeyboardEvent): void;
  72951. /** @hidden */
  72952. private _onCopyText;
  72953. /** @hidden */
  72954. private _onCutText;
  72955. /** @hidden */
  72956. private _onPasteText;
  72957. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72958. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72959. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72960. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72961. protected _beforeRenderText(text: string): string;
  72962. dispose(): void;
  72963. }
  72964. }
  72965. declare module BABYLON.GUI {
  72966. /**
  72967. * Class used to create a 2D grid container
  72968. */
  72969. export class Grid extends Container {
  72970. name?: string | undefined;
  72971. private _rowDefinitions;
  72972. private _columnDefinitions;
  72973. private _cells;
  72974. private _childControls;
  72975. /**
  72976. * Gets the number of columns
  72977. */
  72978. get columnCount(): number;
  72979. /**
  72980. * Gets the number of rows
  72981. */
  72982. get rowCount(): number;
  72983. /** Gets the list of children */
  72984. get children(): Control[];
  72985. /** Gets the list of cells (e.g. the containers) */
  72986. get cells(): {
  72987. [key: string]: Container;
  72988. };
  72989. /**
  72990. * Gets the definition of a specific row
  72991. * @param index defines the index of the row
  72992. * @returns the row definition
  72993. */
  72994. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72995. /**
  72996. * Gets the definition of a specific column
  72997. * @param index defines the index of the column
  72998. * @returns the column definition
  72999. */
  73000. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73001. /**
  73002. * Adds a new row to the grid
  73003. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73004. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73005. * @returns the current grid
  73006. */
  73007. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73008. /**
  73009. * Adds a new column to the grid
  73010. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73011. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73012. * @returns the current grid
  73013. */
  73014. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73015. /**
  73016. * Update a row definition
  73017. * @param index defines the index of the row to update
  73018. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73019. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73020. * @returns the current grid
  73021. */
  73022. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73023. /**
  73024. * Update a column definition
  73025. * @param index defines the index of the column to update
  73026. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73027. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73028. * @returns the current grid
  73029. */
  73030. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73031. /**
  73032. * Gets the list of children stored in a specific cell
  73033. * @param row defines the row to check
  73034. * @param column defines the column to check
  73035. * @returns the list of controls
  73036. */
  73037. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73038. /**
  73039. * Gets a string representing the child cell info (row x column)
  73040. * @param child defines the control to get info from
  73041. * @returns a string containing the child cell info (row x column)
  73042. */
  73043. getChildCellInfo(child: Control): string;
  73044. private _removeCell;
  73045. private _offsetCell;
  73046. /**
  73047. * Remove a column definition at specified index
  73048. * @param index defines the index of the column to remove
  73049. * @returns the current grid
  73050. */
  73051. removeColumnDefinition(index: number): Grid;
  73052. /**
  73053. * Remove a row definition at specified index
  73054. * @param index defines the index of the row to remove
  73055. * @returns the current grid
  73056. */
  73057. removeRowDefinition(index: number): Grid;
  73058. /**
  73059. * Adds a new control to the current grid
  73060. * @param control defines the control to add
  73061. * @param row defines the row where to add the control (0 by default)
  73062. * @param column defines the column where to add the control (0 by default)
  73063. * @returns the current grid
  73064. */
  73065. addControl(control: Control, row?: number, column?: number): Grid;
  73066. /**
  73067. * Removes a control from the current container
  73068. * @param control defines the control to remove
  73069. * @returns the current container
  73070. */
  73071. removeControl(control: Control): Container;
  73072. /**
  73073. * Creates a new Grid
  73074. * @param name defines control name
  73075. */
  73076. constructor(name?: string | undefined);
  73077. protected _getTypeName(): string;
  73078. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73079. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73080. _flagDescendantsAsMatrixDirty(): void;
  73081. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73082. /** Releases associated resources */
  73083. dispose(): void;
  73084. }
  73085. }
  73086. declare module BABYLON.GUI {
  73087. /** Class used to create color pickers */
  73088. export class ColorPicker extends Control {
  73089. name?: string | undefined;
  73090. private static _Epsilon;
  73091. private _colorWheelCanvas;
  73092. private _value;
  73093. private _tmpColor;
  73094. private _pointerStartedOnSquare;
  73095. private _pointerStartedOnWheel;
  73096. private _squareLeft;
  73097. private _squareTop;
  73098. private _squareSize;
  73099. private _h;
  73100. private _s;
  73101. private _v;
  73102. private _lastPointerDownID;
  73103. /**
  73104. * BABYLON.Observable raised when the value changes
  73105. */
  73106. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73107. /** Gets or sets the color of the color picker */
  73108. get value(): BABYLON.Color3;
  73109. set value(value: BABYLON.Color3);
  73110. /**
  73111. * Gets or sets control width
  73112. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73113. */
  73114. get width(): string | number;
  73115. set width(value: string | number);
  73116. /**
  73117. * Gets or sets control height
  73118. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73119. */
  73120. get height(): string | number;
  73121. /** Gets or sets control height */
  73122. set height(value: string | number);
  73123. /** Gets or sets control size */
  73124. get size(): string | number;
  73125. set size(value: string | number);
  73126. /**
  73127. * Creates a new ColorPicker
  73128. * @param name defines the control name
  73129. */
  73130. constructor(name?: string | undefined);
  73131. protected _getTypeName(): string;
  73132. /** @hidden */
  73133. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73134. private _updateSquareProps;
  73135. private _drawGradientSquare;
  73136. private _drawCircle;
  73137. private _createColorWheelCanvas;
  73138. /** @hidden */
  73139. _draw(context: CanvasRenderingContext2D): void;
  73140. private _pointerIsDown;
  73141. private _updateValueFromPointer;
  73142. private _isPointOnSquare;
  73143. private _isPointOnWheel;
  73144. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73145. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73146. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73147. /**
  73148. * This function expands the color picker by creating a color picker dialog with manual
  73149. * color value input and the ability to save colors into an array to be used later in
  73150. * subsequent launches of the dialogue.
  73151. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73152. * @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.
  73153. * @returns picked color as a hex string and the saved colors array as hex strings.
  73154. */
  73155. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73156. pickerWidth?: string;
  73157. pickerHeight?: string;
  73158. headerHeight?: string;
  73159. lastColor?: string;
  73160. swatchLimit?: number;
  73161. numSwatchesPerLine?: number;
  73162. savedColors?: Array<string>;
  73163. }): Promise<{
  73164. savedColors?: string[];
  73165. pickedColor: string;
  73166. }>;
  73167. }
  73168. }
  73169. declare module BABYLON.GUI {
  73170. /** Class used to create 2D ellipse containers */
  73171. export class Ellipse extends Container {
  73172. name?: string | undefined;
  73173. private _thickness;
  73174. /** Gets or sets border thickness */
  73175. get thickness(): number;
  73176. set thickness(value: number);
  73177. /**
  73178. * Creates a new Ellipse
  73179. * @param name defines the control name
  73180. */
  73181. constructor(name?: string | undefined);
  73182. protected _getTypeName(): string;
  73183. protected _localDraw(context: CanvasRenderingContext2D): void;
  73184. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73185. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73186. }
  73187. }
  73188. declare module BABYLON.GUI {
  73189. /**
  73190. * Class used to create a password control
  73191. */
  73192. export class InputPassword extends InputText {
  73193. protected _beforeRenderText(text: string): string;
  73194. }
  73195. }
  73196. declare module BABYLON.GUI {
  73197. /** Class used to render 2D lines */
  73198. export class Line extends Control {
  73199. name?: string | undefined;
  73200. private _lineWidth;
  73201. private _x1;
  73202. private _y1;
  73203. private _x2;
  73204. private _y2;
  73205. private _dash;
  73206. private _connectedControl;
  73207. private _connectedControlDirtyObserver;
  73208. /** Gets or sets the dash pattern */
  73209. get dash(): Array<number>;
  73210. set dash(value: Array<number>);
  73211. /** Gets or sets the control connected with the line end */
  73212. get connectedControl(): Control;
  73213. set connectedControl(value: Control);
  73214. /** Gets or sets start coordinates on X axis */
  73215. get x1(): string | number;
  73216. set x1(value: string | number);
  73217. /** Gets or sets start coordinates on Y axis */
  73218. get y1(): string | number;
  73219. set y1(value: string | number);
  73220. /** Gets or sets end coordinates on X axis */
  73221. get x2(): string | number;
  73222. set x2(value: string | number);
  73223. /** Gets or sets end coordinates on Y axis */
  73224. get y2(): string | number;
  73225. set y2(value: string | number);
  73226. /** Gets or sets line width */
  73227. get lineWidth(): number;
  73228. set lineWidth(value: number);
  73229. /** Gets or sets horizontal alignment */
  73230. set horizontalAlignment(value: number);
  73231. /** Gets or sets vertical alignment */
  73232. set verticalAlignment(value: number);
  73233. private get _effectiveX2();
  73234. private get _effectiveY2();
  73235. /**
  73236. * Creates a new Line
  73237. * @param name defines the control name
  73238. */
  73239. constructor(name?: string | undefined);
  73240. protected _getTypeName(): string;
  73241. _draw(context: CanvasRenderingContext2D): void;
  73242. _measure(): void;
  73243. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73244. /**
  73245. * Move one end of the line given 3D cartesian coordinates.
  73246. * @param position Targeted world position
  73247. * @param scene BABYLON.Scene
  73248. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73249. */
  73250. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73251. /**
  73252. * Move one end of the line to a position in screen absolute space.
  73253. * @param projectedPosition Position in screen absolute space (X, Y)
  73254. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73255. */
  73256. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73257. }
  73258. }
  73259. declare module BABYLON.GUI {
  73260. /**
  73261. * Class used to store a point for a MultiLine object.
  73262. * The point can be pure 2D coordinates, a mesh or a control
  73263. */
  73264. export class MultiLinePoint {
  73265. private _multiLine;
  73266. private _x;
  73267. private _y;
  73268. private _control;
  73269. private _mesh;
  73270. private _controlObserver;
  73271. private _meshObserver;
  73272. /** @hidden */
  73273. _point: BABYLON.Vector2;
  73274. /**
  73275. * Creates a new MultiLinePoint
  73276. * @param multiLine defines the source MultiLine object
  73277. */
  73278. constructor(multiLine: MultiLine);
  73279. /** Gets or sets x coordinate */
  73280. get x(): string | number;
  73281. set x(value: string | number);
  73282. /** Gets or sets y coordinate */
  73283. get y(): string | number;
  73284. set y(value: string | number);
  73285. /** Gets or sets the control associated with this point */
  73286. get control(): BABYLON.Nullable<Control>;
  73287. set control(value: BABYLON.Nullable<Control>);
  73288. /** Gets or sets the mesh associated with this point */
  73289. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73290. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73291. /** Resets links */
  73292. resetLinks(): void;
  73293. /**
  73294. * Gets a translation vector
  73295. * @returns the translation vector
  73296. */
  73297. translate(): BABYLON.Vector2;
  73298. private _translatePoint;
  73299. /** Release associated resources */
  73300. dispose(): void;
  73301. }
  73302. }
  73303. declare module BABYLON.GUI {
  73304. /**
  73305. * Class used to create multi line control
  73306. */
  73307. export class MultiLine extends Control {
  73308. name?: string | undefined;
  73309. private _lineWidth;
  73310. private _dash;
  73311. private _points;
  73312. private _minX;
  73313. private _minY;
  73314. private _maxX;
  73315. private _maxY;
  73316. /**
  73317. * Creates a new MultiLine
  73318. * @param name defines the control name
  73319. */
  73320. constructor(name?: string | undefined);
  73321. /** Gets or sets dash pattern */
  73322. get dash(): Array<number>;
  73323. set dash(value: Array<number>);
  73324. /**
  73325. * Gets point stored at specified index
  73326. * @param index defines the index to look for
  73327. * @returns the requested point if found
  73328. */
  73329. getAt(index: number): MultiLinePoint;
  73330. /** Function called when a point is updated */
  73331. onPointUpdate: () => void;
  73332. /**
  73333. * Adds new points to the point collection
  73334. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73335. * @returns the list of created MultiLinePoint
  73336. */
  73337. add(...items: (AbstractMesh | Control | {
  73338. x: string | number;
  73339. y: string | number;
  73340. })[]): MultiLinePoint[];
  73341. /**
  73342. * Adds a new point to the point collection
  73343. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73344. * @returns the created MultiLinePoint
  73345. */
  73346. push(item?: (AbstractMesh | Control | {
  73347. x: string | number;
  73348. y: string | number;
  73349. })): MultiLinePoint;
  73350. /**
  73351. * Remove a specific value or point from the active point collection
  73352. * @param value defines the value or point to remove
  73353. */
  73354. remove(value: number | MultiLinePoint): void;
  73355. /**
  73356. * Resets this object to initial state (no point)
  73357. */
  73358. reset(): void;
  73359. /**
  73360. * Resets all links
  73361. */
  73362. resetLinks(): void;
  73363. /** Gets or sets line width */
  73364. get lineWidth(): number;
  73365. set lineWidth(value: number);
  73366. set horizontalAlignment(value: number);
  73367. set verticalAlignment(value: number);
  73368. protected _getTypeName(): string;
  73369. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73370. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73371. _measure(): void;
  73372. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73373. dispose(): void;
  73374. }
  73375. }
  73376. declare module BABYLON.GUI {
  73377. /**
  73378. * Class used to create radio button controls
  73379. */
  73380. export class RadioButton extends Control {
  73381. name?: string | undefined;
  73382. private _isChecked;
  73383. private _background;
  73384. private _checkSizeRatio;
  73385. private _thickness;
  73386. /** Gets or sets border thickness */
  73387. get thickness(): number;
  73388. set thickness(value: number);
  73389. /** Gets or sets group name */
  73390. group: string;
  73391. /** BABYLON.Observable raised when isChecked is changed */
  73392. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73393. /** Gets or sets a value indicating the ratio between overall size and check size */
  73394. get checkSizeRatio(): number;
  73395. set checkSizeRatio(value: number);
  73396. /** Gets or sets background color */
  73397. get background(): string;
  73398. set background(value: string);
  73399. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73400. get isChecked(): boolean;
  73401. set isChecked(value: boolean);
  73402. /**
  73403. * Creates a new RadioButton
  73404. * @param name defines the control name
  73405. */
  73406. constructor(name?: string | undefined);
  73407. protected _getTypeName(): string;
  73408. _draw(context: CanvasRenderingContext2D): void;
  73409. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73410. /**
  73411. * Utility function to easily create a radio button with a header
  73412. * @param title defines the label to use for the header
  73413. * @param group defines the group to use for the radio button
  73414. * @param isChecked defines the initial state of the radio button
  73415. * @param onValueChanged defines the callback to call when value changes
  73416. * @returns a StackPanel containing the radio button and a textBlock
  73417. */
  73418. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73419. }
  73420. }
  73421. declare module BABYLON.GUI {
  73422. /**
  73423. * Class used to create slider controls
  73424. */
  73425. export class BaseSlider extends Control {
  73426. name?: string | undefined;
  73427. protected _thumbWidth: ValueAndUnit;
  73428. private _minimum;
  73429. private _maximum;
  73430. private _value;
  73431. private _isVertical;
  73432. protected _barOffset: ValueAndUnit;
  73433. private _isThumbClamped;
  73434. protected _displayThumb: boolean;
  73435. private _step;
  73436. private _lastPointerDownID;
  73437. protected _effectiveBarOffset: number;
  73438. protected _renderLeft: number;
  73439. protected _renderTop: number;
  73440. protected _renderWidth: number;
  73441. protected _renderHeight: number;
  73442. protected _backgroundBoxLength: number;
  73443. protected _backgroundBoxThickness: number;
  73444. protected _effectiveThumbThickness: number;
  73445. /** BABYLON.Observable raised when the sldier value changes */
  73446. onValueChangedObservable: BABYLON.Observable<number>;
  73447. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73448. get displayThumb(): boolean;
  73449. set displayThumb(value: boolean);
  73450. /** Gets or sets a step to apply to values (0 by default) */
  73451. get step(): number;
  73452. set step(value: number);
  73453. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73454. get barOffset(): string | number;
  73455. /** Gets main bar offset in pixels*/
  73456. get barOffsetInPixels(): number;
  73457. set barOffset(value: string | number);
  73458. /** Gets or sets thumb width */
  73459. get thumbWidth(): string | number;
  73460. /** Gets thumb width in pixels */
  73461. get thumbWidthInPixels(): number;
  73462. set thumbWidth(value: string | number);
  73463. /** Gets or sets minimum value */
  73464. get minimum(): number;
  73465. set minimum(value: number);
  73466. /** Gets or sets maximum value */
  73467. get maximum(): number;
  73468. set maximum(value: number);
  73469. /** Gets or sets current value */
  73470. get value(): number;
  73471. set value(value: number);
  73472. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73473. get isVertical(): boolean;
  73474. set isVertical(value: boolean);
  73475. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73476. get isThumbClamped(): boolean;
  73477. set isThumbClamped(value: boolean);
  73478. /**
  73479. * Creates a new BaseSlider
  73480. * @param name defines the control name
  73481. */
  73482. constructor(name?: string | undefined);
  73483. protected _getTypeName(): string;
  73484. protected _getThumbPosition(): number;
  73485. protected _getThumbThickness(type: string): number;
  73486. protected _prepareRenderingData(type: string): void;
  73487. private _pointerIsDown;
  73488. /** @hidden */
  73489. protected _updateValueFromPointer(x: number, y: number): void;
  73490. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73491. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73492. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73493. }
  73494. }
  73495. declare module BABYLON.GUI {
  73496. /**
  73497. * Class used to create slider controls
  73498. */
  73499. export class Slider extends BaseSlider {
  73500. name?: string | undefined;
  73501. private _background;
  73502. private _borderColor;
  73503. private _isThumbCircle;
  73504. protected _displayValueBar: boolean;
  73505. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73506. get displayValueBar(): boolean;
  73507. set displayValueBar(value: boolean);
  73508. /** Gets or sets border color */
  73509. get borderColor(): string;
  73510. set borderColor(value: string);
  73511. /** Gets or sets background color */
  73512. get background(): string;
  73513. set background(value: string);
  73514. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73515. get isThumbCircle(): boolean;
  73516. set isThumbCircle(value: boolean);
  73517. /**
  73518. * Creates a new Slider
  73519. * @param name defines the control name
  73520. */
  73521. constructor(name?: string | undefined);
  73522. protected _getTypeName(): string;
  73523. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73524. }
  73525. }
  73526. declare module BABYLON.GUI {
  73527. /** Class used to create a RadioGroup
  73528. * which contains groups of radio buttons
  73529. */
  73530. export class SelectorGroup {
  73531. /** name of SelectorGroup */
  73532. name: string;
  73533. private _groupPanel;
  73534. private _selectors;
  73535. private _groupHeader;
  73536. /**
  73537. * Creates a new SelectorGroup
  73538. * @param name of group, used as a group heading
  73539. */
  73540. constructor(
  73541. /** name of SelectorGroup */
  73542. name: string);
  73543. /** Gets the groupPanel of the SelectorGroup */
  73544. get groupPanel(): StackPanel;
  73545. /** Gets the selectors array */
  73546. get selectors(): StackPanel[];
  73547. /** Gets and sets the group header */
  73548. get header(): string;
  73549. set header(label: string);
  73550. /** @hidden */
  73551. private _addGroupHeader;
  73552. /** @hidden*/
  73553. _getSelector(selectorNb: number): StackPanel | undefined;
  73554. /** Removes the selector at the given position
  73555. * @param selectorNb the position of the selector within the group
  73556. */
  73557. removeSelector(selectorNb: number): void;
  73558. }
  73559. /** Class used to create a CheckboxGroup
  73560. * which contains groups of checkbox buttons
  73561. */
  73562. export class CheckboxGroup extends SelectorGroup {
  73563. /** Adds a checkbox as a control
  73564. * @param text is the label for the selector
  73565. * @param func is the function called when the Selector is checked
  73566. * @param checked is true when Selector is checked
  73567. */
  73568. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73569. /** @hidden */
  73570. _setSelectorLabel(selectorNb: number, label: string): void;
  73571. /** @hidden */
  73572. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73573. /** @hidden */
  73574. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73575. /** @hidden */
  73576. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73577. }
  73578. /** Class used to create a RadioGroup
  73579. * which contains groups of radio buttons
  73580. */
  73581. export class RadioGroup extends SelectorGroup {
  73582. private _selectNb;
  73583. /** Adds a radio button as a control
  73584. * @param label is the label for the selector
  73585. * @param func is the function called when the Selector is checked
  73586. * @param checked is true when Selector is checked
  73587. */
  73588. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73589. /** @hidden */
  73590. _setSelectorLabel(selectorNb: number, label: string): void;
  73591. /** @hidden */
  73592. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73593. /** @hidden */
  73594. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73595. /** @hidden */
  73596. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73597. }
  73598. /** Class used to create a SliderGroup
  73599. * which contains groups of slider buttons
  73600. */
  73601. export class SliderGroup extends SelectorGroup {
  73602. /**
  73603. * Adds a slider to the SelectorGroup
  73604. * @param label is the label for the SliderBar
  73605. * @param func is the function called when the Slider moves
  73606. * @param unit is a string describing the units used, eg degrees or metres
  73607. * @param min is the minimum value for the Slider
  73608. * @param max is the maximum value for the Slider
  73609. * @param value is the start value for the Slider between min and max
  73610. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73611. */
  73612. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73613. /** @hidden */
  73614. _setSelectorLabel(selectorNb: number, label: string): void;
  73615. /** @hidden */
  73616. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73617. /** @hidden */
  73618. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73619. /** @hidden */
  73620. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73621. }
  73622. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73623. * @see http://doc.babylonjs.com/how_to/selector
  73624. */
  73625. export class SelectionPanel extends Rectangle {
  73626. /** name of SelectionPanel */
  73627. name: string;
  73628. /** an array of SelectionGroups */
  73629. groups: SelectorGroup[];
  73630. private _panel;
  73631. private _buttonColor;
  73632. private _buttonBackground;
  73633. private _headerColor;
  73634. private _barColor;
  73635. private _barHeight;
  73636. private _spacerHeight;
  73637. private _labelColor;
  73638. private _groups;
  73639. private _bars;
  73640. /**
  73641. * Creates a new SelectionPanel
  73642. * @param name of SelectionPanel
  73643. * @param groups is an array of SelectionGroups
  73644. */
  73645. constructor(
  73646. /** name of SelectionPanel */
  73647. name: string,
  73648. /** an array of SelectionGroups */
  73649. groups?: SelectorGroup[]);
  73650. protected _getTypeName(): string;
  73651. /** Gets or sets the headerColor */
  73652. get headerColor(): string;
  73653. set headerColor(color: string);
  73654. private _setHeaderColor;
  73655. /** Gets or sets the button color */
  73656. get buttonColor(): string;
  73657. set buttonColor(color: string);
  73658. private _setbuttonColor;
  73659. /** Gets or sets the label color */
  73660. get labelColor(): string;
  73661. set labelColor(color: string);
  73662. private _setLabelColor;
  73663. /** Gets or sets the button background */
  73664. get buttonBackground(): string;
  73665. set buttonBackground(color: string);
  73666. private _setButtonBackground;
  73667. /** Gets or sets the color of separator bar */
  73668. get barColor(): string;
  73669. set barColor(color: string);
  73670. private _setBarColor;
  73671. /** Gets or sets the height of separator bar */
  73672. get barHeight(): string;
  73673. set barHeight(value: string);
  73674. private _setBarHeight;
  73675. /** Gets or sets the height of spacers*/
  73676. get spacerHeight(): string;
  73677. set spacerHeight(value: string);
  73678. private _setSpacerHeight;
  73679. /** Adds a bar between groups */
  73680. private _addSpacer;
  73681. /** Add a group to the selection panel
  73682. * @param group is the selector group to add
  73683. */
  73684. addGroup(group: SelectorGroup): void;
  73685. /** Remove the group from the given position
  73686. * @param groupNb is the position of the group in the list
  73687. */
  73688. removeGroup(groupNb: number): void;
  73689. /** Change a group header label
  73690. * @param label is the new group header label
  73691. * @param groupNb is the number of the group to relabel
  73692. * */
  73693. setHeaderName(label: string, groupNb: number): void;
  73694. /** Change selector label to the one given
  73695. * @param label is the new selector label
  73696. * @param groupNb is the number of the groupcontaining the selector
  73697. * @param selectorNb is the number of the selector within a group to relabel
  73698. * */
  73699. relabel(label: string, groupNb: number, selectorNb: number): void;
  73700. /** For a given group position remove the selector at the given position
  73701. * @param groupNb is the number of the group to remove the selector from
  73702. * @param selectorNb is the number of the selector within the group
  73703. */
  73704. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73705. /** For a given group position of correct type add a checkbox button
  73706. * @param groupNb is the number of the group to remove the selector from
  73707. * @param label is the label for the selector
  73708. * @param func is the function called when the Selector is checked
  73709. * @param checked is true when Selector is checked
  73710. */
  73711. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73712. /** For a given group position of correct type add a radio button
  73713. * @param groupNb is the number of the group to remove the selector from
  73714. * @param label is the label for the selector
  73715. * @param func is the function called when the Selector is checked
  73716. * @param checked is true when Selector is checked
  73717. */
  73718. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73719. /**
  73720. * For a given slider group add a slider
  73721. * @param groupNb is the number of the group to add the slider to
  73722. * @param label is the label for the Slider
  73723. * @param func is the function called when the Slider moves
  73724. * @param unit is a string describing the units used, eg degrees or metres
  73725. * @param min is the minimum value for the Slider
  73726. * @param max is the maximum value for the Slider
  73727. * @param value is the start value for the Slider between min and max
  73728. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73729. */
  73730. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73731. }
  73732. }
  73733. declare module BABYLON.GUI {
  73734. /**
  73735. * Class used to hold a the container for ScrollViewer
  73736. * @hidden
  73737. */
  73738. export class _ScrollViewerWindow extends Container {
  73739. parentClientWidth: number;
  73740. parentClientHeight: number;
  73741. private _freezeControls;
  73742. private _parentMeasure;
  73743. private _oldLeft;
  73744. private _oldTop;
  73745. get freezeControls(): boolean;
  73746. set freezeControls(value: boolean);
  73747. private _bucketWidth;
  73748. private _bucketHeight;
  73749. private _buckets;
  73750. private _bucketLen;
  73751. get bucketWidth(): number;
  73752. get bucketHeight(): number;
  73753. setBucketSizes(width: number, height: number): void;
  73754. private _useBuckets;
  73755. private _makeBuckets;
  73756. private _dispatchInBuckets;
  73757. private _updateMeasures;
  73758. private _updateChildrenMeasures;
  73759. private _restoreMeasures;
  73760. /**
  73761. * Creates a new ScrollViewerWindow
  73762. * @param name of ScrollViewerWindow
  73763. */
  73764. constructor(name?: string);
  73765. protected _getTypeName(): string;
  73766. /** @hidden */
  73767. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73768. /** @hidden */
  73769. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73770. private _scrollChildren;
  73771. private _scrollChildrenWithBuckets;
  73772. /** @hidden */
  73773. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73774. protected _postMeasure(): void;
  73775. }
  73776. }
  73777. declare module BABYLON.GUI {
  73778. /**
  73779. * Class used to create slider controls
  73780. */
  73781. export class ScrollBar extends BaseSlider {
  73782. name?: string | undefined;
  73783. private _background;
  73784. private _borderColor;
  73785. private _tempMeasure;
  73786. /** Gets or sets border color */
  73787. get borderColor(): string;
  73788. set borderColor(value: string);
  73789. /** Gets or sets background color */
  73790. get background(): string;
  73791. set background(value: string);
  73792. /**
  73793. * Creates a new Slider
  73794. * @param name defines the control name
  73795. */
  73796. constructor(name?: string | undefined);
  73797. protected _getTypeName(): string;
  73798. protected _getThumbThickness(): number;
  73799. _draw(context: CanvasRenderingContext2D): void;
  73800. private _first;
  73801. private _originX;
  73802. private _originY;
  73803. /** @hidden */
  73804. protected _updateValueFromPointer(x: number, y: number): void;
  73805. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73806. }
  73807. }
  73808. declare module BABYLON.GUI {
  73809. /**
  73810. * Class used to create slider controls
  73811. */
  73812. export class ImageScrollBar extends BaseSlider {
  73813. name?: string | undefined;
  73814. private _backgroundBaseImage;
  73815. private _backgroundImage;
  73816. private _thumbImage;
  73817. private _thumbBaseImage;
  73818. private _thumbLength;
  73819. private _thumbHeight;
  73820. private _barImageHeight;
  73821. private _tempMeasure;
  73822. /** Number of 90° rotation to apply on the images when in vertical mode */
  73823. num90RotationInVerticalMode: number;
  73824. /**
  73825. * Gets or sets the image used to render the background for horizontal bar
  73826. */
  73827. get backgroundImage(): Image;
  73828. set backgroundImage(value: Image);
  73829. /**
  73830. * Gets or sets the image used to render the thumb
  73831. */
  73832. get thumbImage(): Image;
  73833. set thumbImage(value: Image);
  73834. /**
  73835. * Gets or sets the length of the thumb
  73836. */
  73837. get thumbLength(): number;
  73838. set thumbLength(value: number);
  73839. /**
  73840. * Gets or sets the height of the thumb
  73841. */
  73842. get thumbHeight(): number;
  73843. set thumbHeight(value: number);
  73844. /**
  73845. * Gets or sets the height of the bar image
  73846. */
  73847. get barImageHeight(): number;
  73848. set barImageHeight(value: number);
  73849. /**
  73850. * Creates a new ImageScrollBar
  73851. * @param name defines the control name
  73852. */
  73853. constructor(name?: string | undefined);
  73854. protected _getTypeName(): string;
  73855. protected _getThumbThickness(): number;
  73856. _draw(context: CanvasRenderingContext2D): void;
  73857. private _first;
  73858. private _originX;
  73859. private _originY;
  73860. /** @hidden */
  73861. protected _updateValueFromPointer(x: number, y: number): void;
  73862. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73863. }
  73864. }
  73865. declare module BABYLON.GUI {
  73866. /**
  73867. * Class used to hold a viewer window and sliders in a grid
  73868. */
  73869. export class ScrollViewer extends Rectangle {
  73870. private _grid;
  73871. private _horizontalBarSpace;
  73872. private _verticalBarSpace;
  73873. private _dragSpace;
  73874. private _horizontalBar;
  73875. private _verticalBar;
  73876. private _barColor;
  73877. private _barBackground;
  73878. private _barImage;
  73879. private _horizontalBarImage;
  73880. private _verticalBarImage;
  73881. private _barBackgroundImage;
  73882. private _horizontalBarBackgroundImage;
  73883. private _verticalBarBackgroundImage;
  73884. private _barSize;
  73885. private _window;
  73886. private _pointerIsOver;
  73887. private _wheelPrecision;
  73888. private _onWheelObserver;
  73889. private _clientWidth;
  73890. private _clientHeight;
  73891. private _useImageBar;
  73892. private _thumbLength;
  73893. private _thumbHeight;
  73894. private _barImageHeight;
  73895. private _horizontalBarImageHeight;
  73896. private _verticalBarImageHeight;
  73897. /**
  73898. * Gets the horizontal scrollbar
  73899. */
  73900. get horizontalBar(): ScrollBar | ImageScrollBar;
  73901. /**
  73902. * Gets the vertical scrollbar
  73903. */
  73904. get verticalBar(): ScrollBar | ImageScrollBar;
  73905. /**
  73906. * Adds a new control to the current container
  73907. * @param control defines the control to add
  73908. * @returns the current container
  73909. */
  73910. addControl(control: BABYLON.Nullable<Control>): Container;
  73911. /**
  73912. * Removes a control from the current container
  73913. * @param control defines the control to remove
  73914. * @returns the current container
  73915. */
  73916. removeControl(control: Control): Container;
  73917. /** Gets the list of children */
  73918. get children(): Control[];
  73919. _flagDescendantsAsMatrixDirty(): void;
  73920. /**
  73921. * Freezes or unfreezes the controls in the window.
  73922. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73923. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73924. */
  73925. get freezeControls(): boolean;
  73926. set freezeControls(value: boolean);
  73927. /** Gets the bucket width */
  73928. get bucketWidth(): number;
  73929. /** Gets the bucket height */
  73930. get bucketHeight(): number;
  73931. /**
  73932. * Sets the bucket sizes.
  73933. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73934. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73935. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73936. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73937. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73938. * used), that's why it is not enabled by default.
  73939. * @param width width of the bucket
  73940. * @param height height of the bucket
  73941. */
  73942. setBucketSizes(width: number, height: number): void;
  73943. private _forceHorizontalBar;
  73944. private _forceVerticalBar;
  73945. /**
  73946. * Forces the horizontal scroll bar to be displayed
  73947. */
  73948. get forceHorizontalBar(): boolean;
  73949. set forceHorizontalBar(value: boolean);
  73950. /**
  73951. * Forces the vertical scroll bar to be displayed
  73952. */
  73953. get forceVerticalBar(): boolean;
  73954. set forceVerticalBar(value: boolean);
  73955. /**
  73956. * Creates a new ScrollViewer
  73957. * @param name of ScrollViewer
  73958. */
  73959. constructor(name?: string, isImageBased?: boolean);
  73960. /** Reset the scroll viewer window to initial size */
  73961. resetWindow(): void;
  73962. protected _getTypeName(): string;
  73963. private _buildClientSizes;
  73964. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73965. protected _postMeasure(): void;
  73966. /**
  73967. * Gets or sets the mouse wheel precision
  73968. * from 0 to 1 with a default value of 0.05
  73969. * */
  73970. get wheelPrecision(): number;
  73971. set wheelPrecision(value: number);
  73972. /** Gets or sets the scroll bar container background color */
  73973. get scrollBackground(): string;
  73974. set scrollBackground(color: string);
  73975. /** Gets or sets the bar color */
  73976. get barColor(): string;
  73977. set barColor(color: string);
  73978. /** Gets or sets the bar image */
  73979. get thumbImage(): Image;
  73980. set thumbImage(value: Image);
  73981. /** Gets or sets the horizontal bar image */
  73982. get horizontalThumbImage(): Image;
  73983. set horizontalThumbImage(value: Image);
  73984. /** Gets or sets the vertical bar image */
  73985. get verticalThumbImage(): Image;
  73986. set verticalThumbImage(value: Image);
  73987. /** Gets or sets the size of the bar */
  73988. get barSize(): number;
  73989. set barSize(value: number);
  73990. /** Gets or sets the length of the thumb */
  73991. get thumbLength(): number;
  73992. set thumbLength(value: number);
  73993. /** Gets or sets the height of the thumb */
  73994. get thumbHeight(): number;
  73995. set thumbHeight(value: number);
  73996. /** Gets or sets the height of the bar image */
  73997. get barImageHeight(): number;
  73998. set barImageHeight(value: number);
  73999. /** Gets or sets the height of the horizontal bar image */
  74000. get horizontalBarImageHeight(): number;
  74001. set horizontalBarImageHeight(value: number);
  74002. /** Gets or sets the height of the vertical bar image */
  74003. get verticalBarImageHeight(): number;
  74004. set verticalBarImageHeight(value: number);
  74005. /** Gets or sets the bar background */
  74006. get barBackground(): string;
  74007. set barBackground(color: string);
  74008. /** Gets or sets the bar background image */
  74009. get barImage(): Image;
  74010. set barImage(value: Image);
  74011. /** Gets or sets the horizontal bar background image */
  74012. get horizontalBarImage(): Image;
  74013. set horizontalBarImage(value: Image);
  74014. /** Gets or sets the vertical bar background image */
  74015. get verticalBarImage(): Image;
  74016. set verticalBarImage(value: Image);
  74017. private _setWindowPosition;
  74018. /** @hidden */
  74019. private _updateScroller;
  74020. _link(host: AdvancedDynamicTexture): void;
  74021. /** @hidden */
  74022. private _addBar;
  74023. /** @hidden */
  74024. private _attachWheel;
  74025. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74026. /** Releases associated resources */
  74027. dispose(): void;
  74028. }
  74029. }
  74030. declare module BABYLON.GUI {
  74031. /** Class used to render a grid */
  74032. export class DisplayGrid extends Control {
  74033. name?: string | undefined;
  74034. private _cellWidth;
  74035. private _cellHeight;
  74036. private _minorLineTickness;
  74037. private _minorLineColor;
  74038. private _majorLineTickness;
  74039. private _majorLineColor;
  74040. private _majorLineFrequency;
  74041. private _background;
  74042. private _displayMajorLines;
  74043. private _displayMinorLines;
  74044. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74045. get displayMinorLines(): boolean;
  74046. set displayMinorLines(value: boolean);
  74047. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74048. get displayMajorLines(): boolean;
  74049. set displayMajorLines(value: boolean);
  74050. /** Gets or sets background color (Black by default) */
  74051. get background(): string;
  74052. set background(value: string);
  74053. /** Gets or sets the width of each cell (20 by default) */
  74054. get cellWidth(): number;
  74055. set cellWidth(value: number);
  74056. /** Gets or sets the height of each cell (20 by default) */
  74057. get cellHeight(): number;
  74058. set cellHeight(value: number);
  74059. /** Gets or sets the tickness of minor lines (1 by default) */
  74060. get minorLineTickness(): number;
  74061. set minorLineTickness(value: number);
  74062. /** Gets or sets the color of minor lines (DarkGray by default) */
  74063. get minorLineColor(): string;
  74064. set minorLineColor(value: string);
  74065. /** Gets or sets the tickness of major lines (2 by default) */
  74066. get majorLineTickness(): number;
  74067. set majorLineTickness(value: number);
  74068. /** Gets or sets the color of major lines (White by default) */
  74069. get majorLineColor(): string;
  74070. set majorLineColor(value: string);
  74071. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74072. get majorLineFrequency(): number;
  74073. set majorLineFrequency(value: number);
  74074. /**
  74075. * Creates a new GridDisplayRectangle
  74076. * @param name defines the control name
  74077. */
  74078. constructor(name?: string | undefined);
  74079. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74080. protected _getTypeName(): string;
  74081. }
  74082. }
  74083. declare module BABYLON.GUI {
  74084. /**
  74085. * Class used to create slider controls based on images
  74086. */
  74087. export class ImageBasedSlider extends BaseSlider {
  74088. name?: string | undefined;
  74089. private _backgroundImage;
  74090. private _thumbImage;
  74091. private _valueBarImage;
  74092. private _tempMeasure;
  74093. get displayThumb(): boolean;
  74094. set displayThumb(value: boolean);
  74095. /**
  74096. * Gets or sets the image used to render the background
  74097. */
  74098. get backgroundImage(): Image;
  74099. set backgroundImage(value: Image);
  74100. /**
  74101. * Gets or sets the image used to render the value bar
  74102. */
  74103. get valueBarImage(): Image;
  74104. set valueBarImage(value: Image);
  74105. /**
  74106. * Gets or sets the image used to render the thumb
  74107. */
  74108. get thumbImage(): Image;
  74109. set thumbImage(value: Image);
  74110. /**
  74111. * Creates a new ImageBasedSlider
  74112. * @param name defines the control name
  74113. */
  74114. constructor(name?: string | undefined);
  74115. protected _getTypeName(): string;
  74116. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74117. }
  74118. }
  74119. declare module BABYLON.GUI {
  74120. /**
  74121. * Forcing an export so that this code will execute
  74122. * @hidden
  74123. */
  74124. const name = "Statics";
  74125. }
  74126. declare module BABYLON.GUI {
  74127. /**
  74128. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74129. */
  74130. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74131. /**
  74132. * Define the instrumented AdvancedDynamicTexture.
  74133. */
  74134. texture: AdvancedDynamicTexture;
  74135. private _captureRenderTime;
  74136. private _renderTime;
  74137. private _captureLayoutTime;
  74138. private _layoutTime;
  74139. private _onBeginRenderObserver;
  74140. private _onEndRenderObserver;
  74141. private _onBeginLayoutObserver;
  74142. private _onEndLayoutObserver;
  74143. /**
  74144. * Gets the perf counter used to capture render time
  74145. */
  74146. get renderTimeCounter(): BABYLON.PerfCounter;
  74147. /**
  74148. * Gets the perf counter used to capture layout time
  74149. */
  74150. get layoutTimeCounter(): BABYLON.PerfCounter;
  74151. /**
  74152. * Enable or disable the render time capture
  74153. */
  74154. get captureRenderTime(): boolean;
  74155. set captureRenderTime(value: boolean);
  74156. /**
  74157. * Enable or disable the layout time capture
  74158. */
  74159. get captureLayoutTime(): boolean;
  74160. set captureLayoutTime(value: boolean);
  74161. /**
  74162. * Instantiates a new advanced dynamic texture instrumentation.
  74163. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74164. * @param texture Defines the AdvancedDynamicTexture to instrument
  74165. */
  74166. constructor(
  74167. /**
  74168. * Define the instrumented AdvancedDynamicTexture.
  74169. */
  74170. texture: AdvancedDynamicTexture);
  74171. /**
  74172. * Dispose and release associated resources.
  74173. */
  74174. dispose(): void;
  74175. }
  74176. }
  74177. declare module BABYLON.GUI {
  74178. /**
  74179. * Class used to load GUI via XML.
  74180. */
  74181. export class XmlLoader {
  74182. private _nodes;
  74183. private _nodeTypes;
  74184. private _isLoaded;
  74185. private _objectAttributes;
  74186. private _parentClass;
  74187. /**
  74188. * Create a new xml loader
  74189. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74190. */
  74191. constructor(parentClass?: null);
  74192. private _getChainElement;
  74193. private _getClassAttribute;
  74194. private _createGuiElement;
  74195. private _parseGrid;
  74196. private _parseElement;
  74197. private _prepareSourceElement;
  74198. private _parseElementsFromSource;
  74199. private _parseXml;
  74200. /**
  74201. * Gets if the loading has finished.
  74202. * @returns whether the loading has finished or not
  74203. */
  74204. isLoaded(): boolean;
  74205. /**
  74206. * Gets a loaded node / control by id.
  74207. * @param id the Controls id set in the xml
  74208. * @returns element of type Control
  74209. */
  74210. getNodeById(id: string): any;
  74211. /**
  74212. * Gets all loaded nodes / controls
  74213. * @returns Array of controls
  74214. */
  74215. getNodes(): any;
  74216. /**
  74217. * Initiates the xml layout loading
  74218. * @param xmlFile defines the xml layout to load
  74219. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74220. * @param callback defines the callback called on layout load.
  74221. */
  74222. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74223. }
  74224. }
  74225. declare module BABYLON.GUI {
  74226. /**
  74227. * Class used to create containers for controls
  74228. */
  74229. export class Container3D extends Control3D {
  74230. private _blockLayout;
  74231. /**
  74232. * Gets the list of child controls
  74233. */
  74234. protected _children: Control3D[];
  74235. /**
  74236. * Gets the list of child controls
  74237. */
  74238. get children(): Array<Control3D>;
  74239. /**
  74240. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74241. * This is helpful to optimize layout operation when adding multiple children in a row
  74242. */
  74243. get blockLayout(): boolean;
  74244. set blockLayout(value: boolean);
  74245. /**
  74246. * Creates a new container
  74247. * @param name defines the container name
  74248. */
  74249. constructor(name?: string);
  74250. /**
  74251. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74252. * @returns the current container
  74253. */
  74254. updateLayout(): Container3D;
  74255. /**
  74256. * Gets a boolean indicating if the given control is in the children of this control
  74257. * @param control defines the control to check
  74258. * @returns true if the control is in the child list
  74259. */
  74260. containsControl(control: Control3D): boolean;
  74261. /**
  74262. * Adds a control to the children of this control
  74263. * @param control defines the control to add
  74264. * @returns the current container
  74265. */
  74266. addControl(control: Control3D): Container3D;
  74267. /**
  74268. * This function will be called everytime a new control is added
  74269. */
  74270. protected _arrangeChildren(): void;
  74271. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74272. /**
  74273. * Removes a control from the children of this control
  74274. * @param control defines the control to remove
  74275. * @returns the current container
  74276. */
  74277. removeControl(control: Control3D): Container3D;
  74278. protected _getTypeName(): string;
  74279. /**
  74280. * Releases all associated resources
  74281. */
  74282. dispose(): void;
  74283. /** Control rotation will remain unchanged */
  74284. static readonly UNSET_ORIENTATION: number;
  74285. /** Control will rotate to make it look at sphere central axis */
  74286. static readonly FACEORIGIN_ORIENTATION: number;
  74287. /** Control will rotate to make it look back at sphere central axis */
  74288. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74289. /** Control will rotate to look at z axis (0, 0, 1) */
  74290. static readonly FACEFORWARD_ORIENTATION: number;
  74291. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74292. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74293. }
  74294. }
  74295. declare module BABYLON.GUI {
  74296. /**
  74297. * Class used to manage 3D user interface
  74298. * @see http://doc.babylonjs.com/how_to/gui3d
  74299. */
  74300. export class GUI3DManager implements BABYLON.IDisposable {
  74301. private _scene;
  74302. private _sceneDisposeObserver;
  74303. private _utilityLayer;
  74304. private _rootContainer;
  74305. private _pointerObserver;
  74306. private _pointerOutObserver;
  74307. /** @hidden */
  74308. _lastPickedControl: Control3D;
  74309. /** @hidden */
  74310. _lastControlOver: {
  74311. [pointerId: number]: Control3D;
  74312. };
  74313. /** @hidden */
  74314. _lastControlDown: {
  74315. [pointerId: number]: Control3D;
  74316. };
  74317. /**
  74318. * BABYLON.Observable raised when the point picked by the pointer events changed
  74319. */
  74320. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74321. /** @hidden */
  74322. _sharedMaterials: {
  74323. [key: string]: BABYLON.Material;
  74324. };
  74325. /** Gets the hosting scene */
  74326. get scene(): BABYLON.Scene;
  74327. /** Gets associated utility layer */
  74328. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74329. /**
  74330. * Creates a new GUI3DManager
  74331. * @param scene
  74332. */
  74333. constructor(scene?: BABYLON.Scene);
  74334. private _handlePointerOut;
  74335. private _doPicking;
  74336. /**
  74337. * Gets the root container
  74338. */
  74339. get rootContainer(): Container3D;
  74340. /**
  74341. * Gets a boolean indicating if the given control is in the root child list
  74342. * @param control defines the control to check
  74343. * @returns true if the control is in the root child list
  74344. */
  74345. containsControl(control: Control3D): boolean;
  74346. /**
  74347. * Adds a control to the root child list
  74348. * @param control defines the control to add
  74349. * @returns the current manager
  74350. */
  74351. addControl(control: Control3D): GUI3DManager;
  74352. /**
  74353. * Removes a control from the root child list
  74354. * @param control defines the control to remove
  74355. * @returns the current container
  74356. */
  74357. removeControl(control: Control3D): GUI3DManager;
  74358. /**
  74359. * Releases all associated resources
  74360. */
  74361. dispose(): void;
  74362. }
  74363. }
  74364. declare module BABYLON.GUI {
  74365. /**
  74366. * Class used to transport BABYLON.Vector3 information for pointer events
  74367. */
  74368. export class Vector3WithInfo extends BABYLON.Vector3 {
  74369. /** defines the current mouse button index */
  74370. buttonIndex: number;
  74371. /**
  74372. * Creates a new Vector3WithInfo
  74373. * @param source defines the vector3 data to transport
  74374. * @param buttonIndex defines the current mouse button index
  74375. */
  74376. constructor(source: BABYLON.Vector3,
  74377. /** defines the current mouse button index */
  74378. buttonIndex?: number);
  74379. }
  74380. }
  74381. declare module BABYLON.GUI {
  74382. /**
  74383. * Class used as base class for controls
  74384. */
  74385. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74386. /** Defines the control name */
  74387. name?: string | undefined;
  74388. /** @hidden */
  74389. _host: GUI3DManager;
  74390. private _node;
  74391. private _downCount;
  74392. private _enterCount;
  74393. private _downPointerIds;
  74394. private _isVisible;
  74395. /** Gets or sets the control position in world space */
  74396. get position(): BABYLON.Vector3;
  74397. set position(value: BABYLON.Vector3);
  74398. /** Gets or sets the control scaling in world space */
  74399. get scaling(): BABYLON.Vector3;
  74400. set scaling(value: BABYLON.Vector3);
  74401. /** Callback used to start pointer enter animation */
  74402. pointerEnterAnimation: () => void;
  74403. /** Callback used to start pointer out animation */
  74404. pointerOutAnimation: () => void;
  74405. /** Callback used to start pointer down animation */
  74406. pointerDownAnimation: () => void;
  74407. /** Callback used to start pointer up animation */
  74408. pointerUpAnimation: () => void;
  74409. /**
  74410. * An event triggered when the pointer move over the control
  74411. */
  74412. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74413. /**
  74414. * An event triggered when the pointer move out of the control
  74415. */
  74416. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74417. /**
  74418. * An event triggered when the pointer taps the control
  74419. */
  74420. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74421. /**
  74422. * An event triggered when pointer is up
  74423. */
  74424. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74425. /**
  74426. * An event triggered when a control is clicked on (with a mouse)
  74427. */
  74428. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74429. /**
  74430. * An event triggered when pointer enters the control
  74431. */
  74432. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74433. /**
  74434. * Gets or sets the parent container
  74435. */
  74436. parent: BABYLON.Nullable<Container3D>;
  74437. private _behaviors;
  74438. /**
  74439. * Gets the list of attached behaviors
  74440. * @see http://doc.babylonjs.com/features/behaviour
  74441. */
  74442. get behaviors(): BABYLON.Behavior<Control3D>[];
  74443. /**
  74444. * Attach a behavior to the control
  74445. * @see http://doc.babylonjs.com/features/behaviour
  74446. * @param behavior defines the behavior to attach
  74447. * @returns the current control
  74448. */
  74449. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74450. /**
  74451. * Remove an attached behavior
  74452. * @see http://doc.babylonjs.com/features/behaviour
  74453. * @param behavior defines the behavior to attach
  74454. * @returns the current control
  74455. */
  74456. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74457. /**
  74458. * Gets an attached behavior by name
  74459. * @param name defines the name of the behavior to look for
  74460. * @see http://doc.babylonjs.com/features/behaviour
  74461. * @returns null if behavior was not found else the requested behavior
  74462. */
  74463. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74464. /** Gets or sets a boolean indicating if the control is visible */
  74465. get isVisible(): boolean;
  74466. set isVisible(value: boolean);
  74467. /**
  74468. * Creates a new control
  74469. * @param name defines the control name
  74470. */
  74471. constructor(
  74472. /** Defines the control name */
  74473. name?: string | undefined);
  74474. /**
  74475. * Gets a string representing the class name
  74476. */
  74477. get typeName(): string;
  74478. /**
  74479. * Get the current class name of the control.
  74480. * @returns current class name
  74481. */
  74482. getClassName(): string;
  74483. protected _getTypeName(): string;
  74484. /**
  74485. * Gets the transform node used by this control
  74486. */
  74487. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74488. /**
  74489. * Gets the mesh used to render this control
  74490. */
  74491. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74492. /**
  74493. * Link the control as child of the given node
  74494. * @param node defines the node to link to. Use null to unlink the control
  74495. * @returns the current control
  74496. */
  74497. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74498. /** @hidden **/
  74499. _prepareNode(scene: BABYLON.Scene): void;
  74500. /**
  74501. * Node creation.
  74502. * Can be overriden by children
  74503. * @param scene defines the scene where the node must be attached
  74504. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74505. */
  74506. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74507. /**
  74508. * Affect a material to the given mesh
  74509. * @param mesh defines the mesh which will represent the control
  74510. */
  74511. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74512. /** @hidden */
  74513. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74514. /** @hidden */
  74515. _onPointerEnter(target: Control3D): boolean;
  74516. /** @hidden */
  74517. _onPointerOut(target: Control3D): void;
  74518. /** @hidden */
  74519. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74520. /** @hidden */
  74521. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74522. /** @hidden */
  74523. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74524. /** @hidden */
  74525. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74526. /** @hidden */
  74527. _disposeNode(): void;
  74528. /**
  74529. * Releases all associated resources
  74530. */
  74531. dispose(): void;
  74532. }
  74533. }
  74534. declare module BABYLON.GUI {
  74535. /**
  74536. * Class used as a root to all buttons
  74537. */
  74538. export class AbstractButton3D extends Control3D {
  74539. /**
  74540. * Creates a new button
  74541. * @param name defines the control name
  74542. */
  74543. constructor(name?: string);
  74544. protected _getTypeName(): string;
  74545. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74546. }
  74547. }
  74548. declare module BABYLON.GUI {
  74549. /**
  74550. * Class used to create a button in 3D
  74551. */
  74552. export class Button3D extends AbstractButton3D {
  74553. /** @hidden */
  74554. protected _currentMaterial: BABYLON.Material;
  74555. private _facadeTexture;
  74556. private _content;
  74557. private _contentResolution;
  74558. private _contentScaleRatio;
  74559. /**
  74560. * Gets or sets the texture resolution used to render content (512 by default)
  74561. */
  74562. get contentResolution(): BABYLON.int;
  74563. set contentResolution(value: BABYLON.int);
  74564. /**
  74565. * Gets or sets the texture scale ratio used to render content (2 by default)
  74566. */
  74567. get contentScaleRatio(): number;
  74568. set contentScaleRatio(value: number);
  74569. protected _disposeFacadeTexture(): void;
  74570. protected _resetContent(): void;
  74571. /**
  74572. * Creates a new button
  74573. * @param name defines the control name
  74574. */
  74575. constructor(name?: string);
  74576. /**
  74577. * Gets or sets the GUI 2D content used to display the button's facade
  74578. */
  74579. get content(): Control;
  74580. set content(value: Control);
  74581. /**
  74582. * Apply the facade texture (created from the content property).
  74583. * This function can be overloaded by child classes
  74584. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74585. */
  74586. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74587. protected _getTypeName(): string;
  74588. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74589. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74590. /**
  74591. * Releases all associated resources
  74592. */
  74593. dispose(): void;
  74594. }
  74595. }
  74596. declare module BABYLON.GUI {
  74597. /**
  74598. * Abstract class used to create a container panel deployed on the surface of a volume
  74599. */
  74600. export abstract class VolumeBasedPanel extends Container3D {
  74601. private _columns;
  74602. private _rows;
  74603. private _rowThenColum;
  74604. private _orientation;
  74605. protected _cellWidth: number;
  74606. protected _cellHeight: number;
  74607. /**
  74608. * Gets or sets the distance between elements
  74609. */
  74610. margin: number;
  74611. /**
  74612. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74613. * | Value | Type | Description |
  74614. * | ----- | ----------------------------------- | ----------- |
  74615. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74616. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74617. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74618. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74619. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74620. */
  74621. get orientation(): number;
  74622. set orientation(value: number);
  74623. /**
  74624. * Gets or sets the number of columns requested (10 by default).
  74625. * The panel will automatically compute the number of rows based on number of child controls.
  74626. */
  74627. get columns(): BABYLON.int;
  74628. set columns(value: BABYLON.int);
  74629. /**
  74630. * Gets or sets a the number of rows requested.
  74631. * The panel will automatically compute the number of columns based on number of child controls.
  74632. */
  74633. get rows(): BABYLON.int;
  74634. set rows(value: BABYLON.int);
  74635. /**
  74636. * Creates new VolumeBasedPanel
  74637. */
  74638. constructor();
  74639. protected _arrangeChildren(): void;
  74640. /** Child classes must implement this function to provide correct control positioning */
  74641. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74642. /** Child classes can implement this function to provide additional processing */
  74643. protected _finalProcessing(): void;
  74644. }
  74645. }
  74646. declare module BABYLON.GUI {
  74647. /**
  74648. * Class used to create a container panel deployed on the surface of a cylinder
  74649. */
  74650. export class CylinderPanel extends VolumeBasedPanel {
  74651. private _radius;
  74652. /**
  74653. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74654. */
  74655. get radius(): BABYLON.float;
  74656. set radius(value: BABYLON.float);
  74657. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74658. private _cylindricalMapping;
  74659. }
  74660. }
  74661. declare module BABYLON.GUI {
  74662. /** @hidden */
  74663. export var fluentVertexShader: {
  74664. name: string;
  74665. shader: string;
  74666. };
  74667. }
  74668. declare module BABYLON.GUI {
  74669. /** @hidden */
  74670. export var fluentPixelShader: {
  74671. name: string;
  74672. shader: string;
  74673. };
  74674. }
  74675. declare module BABYLON.GUI {
  74676. /** @hidden */
  74677. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74678. INNERGLOW: boolean;
  74679. BORDER: boolean;
  74680. HOVERLIGHT: boolean;
  74681. TEXTURE: boolean;
  74682. constructor();
  74683. }
  74684. /**
  74685. * Class used to render controls with fluent desgin
  74686. */
  74687. export class FluentMaterial extends BABYLON.PushMaterial {
  74688. /**
  74689. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74690. */
  74691. innerGlowColorIntensity: number;
  74692. /**
  74693. * Gets or sets the inner glow color (white by default)
  74694. */
  74695. innerGlowColor: BABYLON.Color3;
  74696. /**
  74697. * Gets or sets alpha value (default is 1.0)
  74698. */
  74699. alpha: number;
  74700. /**
  74701. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74702. */
  74703. albedoColor: BABYLON.Color3;
  74704. /**
  74705. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74706. */
  74707. renderBorders: boolean;
  74708. /**
  74709. * Gets or sets border width (default is 0.5)
  74710. */
  74711. borderWidth: number;
  74712. /**
  74713. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74714. */
  74715. edgeSmoothingValue: number;
  74716. /**
  74717. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74718. */
  74719. borderMinValue: number;
  74720. /**
  74721. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74722. */
  74723. renderHoverLight: boolean;
  74724. /**
  74725. * Gets or sets the radius used to render the hover light (default is 1.0)
  74726. */
  74727. hoverRadius: number;
  74728. /**
  74729. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74730. */
  74731. hoverColor: BABYLON.Color4;
  74732. /**
  74733. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74734. */
  74735. hoverPosition: BABYLON.Vector3;
  74736. private _albedoTexture;
  74737. /** Gets or sets the texture to use for albedo color */
  74738. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74739. /**
  74740. * Creates a new Fluent material
  74741. * @param name defines the name of the material
  74742. * @param scene defines the hosting scene
  74743. */
  74744. constructor(name: string, scene: BABYLON.Scene);
  74745. needAlphaBlending(): boolean;
  74746. needAlphaTesting(): boolean;
  74747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74748. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74749. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74750. getActiveTextures(): BABYLON.BaseTexture[];
  74751. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74752. dispose(forceDisposeEffect?: boolean): void;
  74753. clone(name: string): FluentMaterial;
  74754. serialize(): any;
  74755. getClassName(): string;
  74756. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74757. }
  74758. }
  74759. declare module BABYLON.GUI {
  74760. /**
  74761. * Class used to create a holographic button in 3D
  74762. */
  74763. export class HolographicButton extends Button3D {
  74764. private _backPlate;
  74765. private _textPlate;
  74766. private _frontPlate;
  74767. private _text;
  74768. private _imageUrl;
  74769. private _shareMaterials;
  74770. private _frontMaterial;
  74771. private _backMaterial;
  74772. private _plateMaterial;
  74773. private _pickedPointObserver;
  74774. private _tooltipFade;
  74775. private _tooltipTextBlock;
  74776. private _tooltipTexture;
  74777. private _tooltipMesh;
  74778. private _tooltipHoverObserver;
  74779. private _tooltipOutObserver;
  74780. private _disposeTooltip;
  74781. /**
  74782. * Rendering ground id of all the mesh in the button
  74783. */
  74784. set renderingGroupId(id: number);
  74785. get renderingGroupId(): number;
  74786. /**
  74787. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74788. */
  74789. set tooltipText(text: BABYLON.Nullable<string>);
  74790. get tooltipText(): BABYLON.Nullable<string>;
  74791. /**
  74792. * Gets or sets text for the button
  74793. */
  74794. get text(): string;
  74795. set text(value: string);
  74796. /**
  74797. * Gets or sets the image url for the button
  74798. */
  74799. get imageUrl(): string;
  74800. set imageUrl(value: string);
  74801. /**
  74802. * Gets the back material used by this button
  74803. */
  74804. get backMaterial(): FluentMaterial;
  74805. /**
  74806. * Gets the front material used by this button
  74807. */
  74808. get frontMaterial(): FluentMaterial;
  74809. /**
  74810. * Gets the plate material used by this button
  74811. */
  74812. get plateMaterial(): BABYLON.StandardMaterial;
  74813. /**
  74814. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74815. */
  74816. get shareMaterials(): boolean;
  74817. /**
  74818. * Creates a new button
  74819. * @param name defines the control name
  74820. */
  74821. constructor(name?: string, shareMaterials?: boolean);
  74822. protected _getTypeName(): string;
  74823. private _rebuildContent;
  74824. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74825. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74826. private _createBackMaterial;
  74827. private _createFrontMaterial;
  74828. private _createPlateMaterial;
  74829. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74830. /**
  74831. * Releases all associated resources
  74832. */
  74833. dispose(): void;
  74834. }
  74835. }
  74836. declare module BABYLON.GUI {
  74837. /**
  74838. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74839. */
  74840. export class MeshButton3D extends Button3D {
  74841. /** @hidden */
  74842. protected _currentMesh: BABYLON.Mesh;
  74843. /**
  74844. * Creates a new 3D button based on a mesh
  74845. * @param mesh mesh to become a 3D button
  74846. * @param name defines the control name
  74847. */
  74848. constructor(mesh: BABYLON.Mesh, name?: string);
  74849. protected _getTypeName(): string;
  74850. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74851. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74852. }
  74853. }
  74854. declare module BABYLON.GUI {
  74855. /**
  74856. * Class used to create a container panel deployed on the surface of a plane
  74857. */
  74858. export class PlanePanel extends VolumeBasedPanel {
  74859. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74860. }
  74861. }
  74862. declare module BABYLON.GUI {
  74863. /**
  74864. * Class used to create a container panel where items get randomized planar mapping
  74865. */
  74866. export class ScatterPanel extends VolumeBasedPanel {
  74867. private _iteration;
  74868. /**
  74869. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74870. */
  74871. get iteration(): BABYLON.float;
  74872. set iteration(value: BABYLON.float);
  74873. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74874. private _scatterMapping;
  74875. protected _finalProcessing(): void;
  74876. }
  74877. }
  74878. declare module BABYLON.GUI {
  74879. /**
  74880. * Class used to create a container panel deployed on the surface of a sphere
  74881. */
  74882. export class SpherePanel extends VolumeBasedPanel {
  74883. private _radius;
  74884. /**
  74885. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74886. */
  74887. get radius(): BABYLON.float;
  74888. set radius(value: BABYLON.float);
  74889. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74890. private _sphericalMapping;
  74891. }
  74892. }
  74893. declare module BABYLON.GUI {
  74894. /**
  74895. * Class used to create a stack panel in 3D on XY plane
  74896. */
  74897. export class StackPanel3D extends Container3D {
  74898. private _isVertical;
  74899. /**
  74900. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74901. */
  74902. get isVertical(): boolean;
  74903. set isVertical(value: boolean);
  74904. /**
  74905. * Gets or sets the distance between elements
  74906. */
  74907. margin: number;
  74908. /**
  74909. * Creates new StackPanel
  74910. * @param isVertical
  74911. */
  74912. constructor(isVertical?: boolean);
  74913. protected _arrangeChildren(): void;
  74914. }
  74915. }
  74916. declare module BABYLON {
  74917. /**
  74918. * Configuration for glTF validation
  74919. */
  74920. export interface IGLTFValidationConfiguration {
  74921. /**
  74922. * The url of the glTF validator.
  74923. */
  74924. url: string;
  74925. }
  74926. /**
  74927. * glTF validation
  74928. */
  74929. export class GLTFValidation {
  74930. /**
  74931. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74932. */
  74933. static Configuration: IGLTFValidationConfiguration;
  74934. private static _LoadScriptPromise;
  74935. /**
  74936. * Validate a glTF asset using the glTF-Validator.
  74937. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74938. * @param rootUrl The root url for the glTF
  74939. * @param fileName The file name for the glTF
  74940. * @param getExternalResource The callback to get external resources for the glTF validator
  74941. * @returns A promise that resolves with the glTF validation results once complete
  74942. */
  74943. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74944. }
  74945. }
  74946. declare module BABYLON {
  74947. /**
  74948. * Mode that determines the coordinate system to use.
  74949. */
  74950. export enum GLTFLoaderCoordinateSystemMode {
  74951. /**
  74952. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74953. */
  74954. AUTO = 0,
  74955. /**
  74956. * Sets the useRightHandedSystem flag on the scene.
  74957. */
  74958. FORCE_RIGHT_HANDED = 1
  74959. }
  74960. /**
  74961. * Mode that determines what animations will start.
  74962. */
  74963. export enum GLTFLoaderAnimationStartMode {
  74964. /**
  74965. * No animation will start.
  74966. */
  74967. NONE = 0,
  74968. /**
  74969. * The first animation will start.
  74970. */
  74971. FIRST = 1,
  74972. /**
  74973. * All animations will start.
  74974. */
  74975. ALL = 2
  74976. }
  74977. /**
  74978. * Interface that contains the data for the glTF asset.
  74979. */
  74980. export interface IGLTFLoaderData {
  74981. /**
  74982. * The object that represents the glTF JSON.
  74983. */
  74984. json: Object;
  74985. /**
  74986. * The BIN chunk of a binary glTF.
  74987. */
  74988. bin: Nullable<IDataBuffer>;
  74989. }
  74990. /**
  74991. * Interface for extending the loader.
  74992. */
  74993. export interface IGLTFLoaderExtension {
  74994. /**
  74995. * The name of this extension.
  74996. */
  74997. readonly name: string;
  74998. /**
  74999. * Defines whether this extension is enabled.
  75000. */
  75001. enabled: boolean;
  75002. /**
  75003. * Defines the order of this extension.
  75004. * The loader sorts the extensions using these values when loading.
  75005. */
  75006. order?: number;
  75007. }
  75008. /**
  75009. * Loader state.
  75010. */
  75011. export enum GLTFLoaderState {
  75012. /**
  75013. * The asset is loading.
  75014. */
  75015. LOADING = 0,
  75016. /**
  75017. * The asset is ready for rendering.
  75018. */
  75019. READY = 1,
  75020. /**
  75021. * The asset is completely loaded.
  75022. */
  75023. COMPLETE = 2
  75024. }
  75025. /** @hidden */
  75026. export interface IImportMeshAsyncOutput {
  75027. meshes: AbstractMesh[];
  75028. particleSystems: IParticleSystem[];
  75029. skeletons: Skeleton[];
  75030. animationGroups: AnimationGroup[];
  75031. lights: Light[];
  75032. transformNodes: TransformNode[];
  75033. }
  75034. /** @hidden */
  75035. export interface IGLTFLoader extends IDisposable {
  75036. readonly state: Nullable<GLTFLoaderState>;
  75037. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75038. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75039. }
  75040. /**
  75041. * File loader for loading glTF files into a scene.
  75042. */
  75043. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75044. /** @hidden */
  75045. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75046. /** @hidden */
  75047. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75048. /**
  75049. * Raised when the asset has been parsed
  75050. */
  75051. onParsedObservable: Observable<IGLTFLoaderData>;
  75052. private _onParsedObserver;
  75053. /**
  75054. * Raised when the asset has been parsed
  75055. */
  75056. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75057. /**
  75058. * 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.
  75059. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75060. * Defaults to true.
  75061. * @hidden
  75062. */
  75063. static IncrementalLoading: boolean;
  75064. /**
  75065. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75066. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75067. * @hidden
  75068. */
  75069. static HomogeneousCoordinates: boolean;
  75070. /**
  75071. * The coordinate system mode. Defaults to AUTO.
  75072. */
  75073. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75074. /**
  75075. * The animation start mode. Defaults to FIRST.
  75076. */
  75077. animationStartMode: GLTFLoaderAnimationStartMode;
  75078. /**
  75079. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75080. */
  75081. compileMaterials: boolean;
  75082. /**
  75083. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75084. */
  75085. useClipPlane: boolean;
  75086. /**
  75087. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75088. */
  75089. compileShadowGenerators: boolean;
  75090. /**
  75091. * Defines if the Alpha blended materials are only applied as coverage.
  75092. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75093. * If true, no extra effects are applied to transparent pixels.
  75094. */
  75095. transparencyAsCoverage: boolean;
  75096. /**
  75097. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75098. * Enabling will disable offline support and glTF validator.
  75099. * Defaults to false.
  75100. */
  75101. useRangeRequests: boolean;
  75102. /**
  75103. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75104. */
  75105. createInstances: boolean;
  75106. /**
  75107. * Function called before loading a url referenced by the asset.
  75108. */
  75109. preprocessUrlAsync: (url: string) => Promise<string>;
  75110. /**
  75111. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75112. */
  75113. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75114. private _onMeshLoadedObserver;
  75115. /**
  75116. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75117. */
  75118. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75119. /**
  75120. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75121. */
  75122. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75123. private _onTextureLoadedObserver;
  75124. /**
  75125. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75126. */
  75127. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75128. /**
  75129. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75130. */
  75131. readonly onMaterialLoadedObservable: Observable<Material>;
  75132. private _onMaterialLoadedObserver;
  75133. /**
  75134. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75135. */
  75136. set onMaterialLoaded(callback: (material: Material) => void);
  75137. /**
  75138. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75139. */
  75140. readonly onCameraLoadedObservable: Observable<Camera>;
  75141. private _onCameraLoadedObserver;
  75142. /**
  75143. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75144. */
  75145. set onCameraLoaded(callback: (camera: Camera) => void);
  75146. /**
  75147. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75148. * For assets with LODs, raised when all of the LODs are complete.
  75149. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75150. */
  75151. readonly onCompleteObservable: Observable<void>;
  75152. private _onCompleteObserver;
  75153. /**
  75154. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75155. * For assets with LODs, raised when all of the LODs are complete.
  75156. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75157. */
  75158. set onComplete(callback: () => void);
  75159. /**
  75160. * Observable raised when an error occurs.
  75161. */
  75162. readonly onErrorObservable: Observable<any>;
  75163. private _onErrorObserver;
  75164. /**
  75165. * Callback raised when an error occurs.
  75166. */
  75167. set onError(callback: (reason: any) => void);
  75168. /**
  75169. * Observable raised after the loader is disposed.
  75170. */
  75171. readonly onDisposeObservable: Observable<void>;
  75172. private _onDisposeObserver;
  75173. /**
  75174. * Callback raised after the loader is disposed.
  75175. */
  75176. set onDispose(callback: () => void);
  75177. /**
  75178. * Observable raised after a loader extension is created.
  75179. * Set additional options for a loader extension in this event.
  75180. */
  75181. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75182. private _onExtensionLoadedObserver;
  75183. /**
  75184. * Callback raised after a loader extension is created.
  75185. */
  75186. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75187. /**
  75188. * Defines if the loader logging is enabled.
  75189. */
  75190. get loggingEnabled(): boolean;
  75191. set loggingEnabled(value: boolean);
  75192. /**
  75193. * Defines if the loader should capture performance counters.
  75194. */
  75195. get capturePerformanceCounters(): boolean;
  75196. set capturePerformanceCounters(value: boolean);
  75197. /**
  75198. * Defines if the loader should validate the asset.
  75199. */
  75200. validate: boolean;
  75201. /**
  75202. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75203. */
  75204. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75205. private _onValidatedObserver;
  75206. /**
  75207. * Callback raised after a loader extension is created.
  75208. */
  75209. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75210. private _loader;
  75211. /**
  75212. * Name of the loader ("gltf")
  75213. */
  75214. name: string;
  75215. /** @hidden */
  75216. extensions: ISceneLoaderPluginExtensions;
  75217. /**
  75218. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75219. */
  75220. dispose(): void;
  75221. /** @hidden */
  75222. _clear(): void;
  75223. /** @hidden */
  75224. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75225. /** @hidden */
  75226. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75227. /** @hidden */
  75228. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75229. meshes: AbstractMesh[];
  75230. particleSystems: IParticleSystem[];
  75231. skeletons: Skeleton[];
  75232. animationGroups: AnimationGroup[];
  75233. }>;
  75234. /** @hidden */
  75235. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75236. /** @hidden */
  75237. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75238. /** @hidden */
  75239. canDirectLoad(data: string): boolean;
  75240. /** @hidden */
  75241. directLoad(scene: Scene, data: string): any;
  75242. /**
  75243. * The callback that allows custom handling of the root url based on the response url.
  75244. * @param rootUrl the original root url
  75245. * @param responseURL the response url if available
  75246. * @returns the new root url
  75247. */
  75248. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75249. /** @hidden */
  75250. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75251. /**
  75252. * The loader state or null if the loader is not active.
  75253. */
  75254. get loaderState(): Nullable<GLTFLoaderState>;
  75255. /**
  75256. * Returns a promise that resolves when the asset is completely loaded.
  75257. * @returns a promise that resolves when the asset is completely loaded.
  75258. */
  75259. whenCompleteAsync(): Promise<void>;
  75260. private _validate;
  75261. private _getLoader;
  75262. private _parseJson;
  75263. private _unpackBinaryAsync;
  75264. private _unpackBinaryV1Async;
  75265. private _unpackBinaryV2Async;
  75266. private static _parseVersion;
  75267. private static _compareVersion;
  75268. private static readonly _logSpaces;
  75269. private _logIndentLevel;
  75270. private _loggingEnabled;
  75271. /** @hidden */
  75272. _log: (message: string) => void;
  75273. /** @hidden */
  75274. _logOpen(message: string): void;
  75275. /** @hidden */
  75276. _logClose(): void;
  75277. private _logEnabled;
  75278. private _logDisabled;
  75279. private _capturePerformanceCounters;
  75280. /** @hidden */
  75281. _startPerformanceCounter: (counterName: string) => void;
  75282. /** @hidden */
  75283. _endPerformanceCounter: (counterName: string) => void;
  75284. private _startPerformanceCounterEnabled;
  75285. private _startPerformanceCounterDisabled;
  75286. private _endPerformanceCounterEnabled;
  75287. private _endPerformanceCounterDisabled;
  75288. }
  75289. }
  75290. declare module BABYLON.GLTF1 {
  75291. /**
  75292. * Enums
  75293. * @hidden
  75294. */
  75295. export enum EComponentType {
  75296. BYTE = 5120,
  75297. UNSIGNED_BYTE = 5121,
  75298. SHORT = 5122,
  75299. UNSIGNED_SHORT = 5123,
  75300. FLOAT = 5126
  75301. }
  75302. /** @hidden */
  75303. export enum EShaderType {
  75304. FRAGMENT = 35632,
  75305. VERTEX = 35633
  75306. }
  75307. /** @hidden */
  75308. export enum EParameterType {
  75309. BYTE = 5120,
  75310. UNSIGNED_BYTE = 5121,
  75311. SHORT = 5122,
  75312. UNSIGNED_SHORT = 5123,
  75313. INT = 5124,
  75314. UNSIGNED_INT = 5125,
  75315. FLOAT = 5126,
  75316. FLOAT_VEC2 = 35664,
  75317. FLOAT_VEC3 = 35665,
  75318. FLOAT_VEC4 = 35666,
  75319. INT_VEC2 = 35667,
  75320. INT_VEC3 = 35668,
  75321. INT_VEC4 = 35669,
  75322. BOOL = 35670,
  75323. BOOL_VEC2 = 35671,
  75324. BOOL_VEC3 = 35672,
  75325. BOOL_VEC4 = 35673,
  75326. FLOAT_MAT2 = 35674,
  75327. FLOAT_MAT3 = 35675,
  75328. FLOAT_MAT4 = 35676,
  75329. SAMPLER_2D = 35678
  75330. }
  75331. /** @hidden */
  75332. export enum ETextureWrapMode {
  75333. CLAMP_TO_EDGE = 33071,
  75334. MIRRORED_REPEAT = 33648,
  75335. REPEAT = 10497
  75336. }
  75337. /** @hidden */
  75338. export enum ETextureFilterType {
  75339. NEAREST = 9728,
  75340. LINEAR = 9728,
  75341. NEAREST_MIPMAP_NEAREST = 9984,
  75342. LINEAR_MIPMAP_NEAREST = 9985,
  75343. NEAREST_MIPMAP_LINEAR = 9986,
  75344. LINEAR_MIPMAP_LINEAR = 9987
  75345. }
  75346. /** @hidden */
  75347. export enum ETextureFormat {
  75348. ALPHA = 6406,
  75349. RGB = 6407,
  75350. RGBA = 6408,
  75351. LUMINANCE = 6409,
  75352. LUMINANCE_ALPHA = 6410
  75353. }
  75354. /** @hidden */
  75355. export enum ECullingType {
  75356. FRONT = 1028,
  75357. BACK = 1029,
  75358. FRONT_AND_BACK = 1032
  75359. }
  75360. /** @hidden */
  75361. export enum EBlendingFunction {
  75362. ZERO = 0,
  75363. ONE = 1,
  75364. SRC_COLOR = 768,
  75365. ONE_MINUS_SRC_COLOR = 769,
  75366. DST_COLOR = 774,
  75367. ONE_MINUS_DST_COLOR = 775,
  75368. SRC_ALPHA = 770,
  75369. ONE_MINUS_SRC_ALPHA = 771,
  75370. DST_ALPHA = 772,
  75371. ONE_MINUS_DST_ALPHA = 773,
  75372. CONSTANT_COLOR = 32769,
  75373. ONE_MINUS_CONSTANT_COLOR = 32770,
  75374. CONSTANT_ALPHA = 32771,
  75375. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75376. SRC_ALPHA_SATURATE = 776
  75377. }
  75378. /** @hidden */
  75379. export interface IGLTFProperty {
  75380. extensions?: {
  75381. [key: string]: any;
  75382. };
  75383. extras?: Object;
  75384. }
  75385. /** @hidden */
  75386. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75387. name?: string;
  75388. }
  75389. /** @hidden */
  75390. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75391. bufferView: string;
  75392. byteOffset: number;
  75393. byteStride: number;
  75394. count: number;
  75395. type: string;
  75396. componentType: EComponentType;
  75397. max?: number[];
  75398. min?: number[];
  75399. name?: string;
  75400. }
  75401. /** @hidden */
  75402. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75403. buffer: string;
  75404. byteOffset: number;
  75405. byteLength: number;
  75406. byteStride: number;
  75407. target?: number;
  75408. }
  75409. /** @hidden */
  75410. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75411. uri: string;
  75412. byteLength?: number;
  75413. type?: string;
  75414. }
  75415. /** @hidden */
  75416. export interface IGLTFShader extends IGLTFChildRootProperty {
  75417. uri: string;
  75418. type: EShaderType;
  75419. }
  75420. /** @hidden */
  75421. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75422. attributes: string[];
  75423. fragmentShader: string;
  75424. vertexShader: string;
  75425. }
  75426. /** @hidden */
  75427. export interface IGLTFTechniqueParameter {
  75428. type: number;
  75429. count?: number;
  75430. semantic?: string;
  75431. node?: string;
  75432. value?: number | boolean | string | Array<any>;
  75433. source?: string;
  75434. babylonValue?: any;
  75435. }
  75436. /** @hidden */
  75437. export interface IGLTFTechniqueCommonProfile {
  75438. lightingModel: string;
  75439. texcoordBindings: Object;
  75440. parameters?: Array<any>;
  75441. }
  75442. /** @hidden */
  75443. export interface IGLTFTechniqueStatesFunctions {
  75444. blendColor?: number[];
  75445. blendEquationSeparate?: number[];
  75446. blendFuncSeparate?: number[];
  75447. colorMask: boolean[];
  75448. cullFace: number[];
  75449. }
  75450. /** @hidden */
  75451. export interface IGLTFTechniqueStates {
  75452. enable: number[];
  75453. functions: IGLTFTechniqueStatesFunctions;
  75454. }
  75455. /** @hidden */
  75456. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75457. parameters: {
  75458. [key: string]: IGLTFTechniqueParameter;
  75459. };
  75460. program: string;
  75461. attributes: {
  75462. [key: string]: string;
  75463. };
  75464. uniforms: {
  75465. [key: string]: string;
  75466. };
  75467. states: IGLTFTechniqueStates;
  75468. }
  75469. /** @hidden */
  75470. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75471. technique?: string;
  75472. values: string[];
  75473. }
  75474. /** @hidden */
  75475. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75476. attributes: {
  75477. [key: string]: string;
  75478. };
  75479. indices: string;
  75480. material: string;
  75481. mode?: number;
  75482. }
  75483. /** @hidden */
  75484. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75485. primitives: IGLTFMeshPrimitive[];
  75486. }
  75487. /** @hidden */
  75488. export interface IGLTFImage extends IGLTFChildRootProperty {
  75489. uri: string;
  75490. }
  75491. /** @hidden */
  75492. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75493. magFilter?: number;
  75494. minFilter?: number;
  75495. wrapS?: number;
  75496. wrapT?: number;
  75497. }
  75498. /** @hidden */
  75499. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75500. sampler: string;
  75501. source: string;
  75502. format?: ETextureFormat;
  75503. internalFormat?: ETextureFormat;
  75504. target?: number;
  75505. type?: number;
  75506. babylonTexture?: Texture;
  75507. }
  75508. /** @hidden */
  75509. export interface IGLTFAmbienLight {
  75510. color?: number[];
  75511. }
  75512. /** @hidden */
  75513. export interface IGLTFDirectionalLight {
  75514. color?: number[];
  75515. }
  75516. /** @hidden */
  75517. export interface IGLTFPointLight {
  75518. color?: number[];
  75519. constantAttenuation?: number;
  75520. linearAttenuation?: number;
  75521. quadraticAttenuation?: number;
  75522. }
  75523. /** @hidden */
  75524. export interface IGLTFSpotLight {
  75525. color?: number[];
  75526. constantAttenuation?: number;
  75527. fallOfAngle?: number;
  75528. fallOffExponent?: number;
  75529. linearAttenuation?: number;
  75530. quadraticAttenuation?: number;
  75531. }
  75532. /** @hidden */
  75533. export interface IGLTFLight extends IGLTFChildRootProperty {
  75534. type: string;
  75535. }
  75536. /** @hidden */
  75537. export interface IGLTFCameraOrthographic {
  75538. xmag: number;
  75539. ymag: number;
  75540. zfar: number;
  75541. znear: number;
  75542. }
  75543. /** @hidden */
  75544. export interface IGLTFCameraPerspective {
  75545. aspectRatio: number;
  75546. yfov: number;
  75547. zfar: number;
  75548. znear: number;
  75549. }
  75550. /** @hidden */
  75551. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75552. type: string;
  75553. }
  75554. /** @hidden */
  75555. export interface IGLTFAnimationChannelTarget {
  75556. id: string;
  75557. path: string;
  75558. }
  75559. /** @hidden */
  75560. export interface IGLTFAnimationChannel {
  75561. sampler: string;
  75562. target: IGLTFAnimationChannelTarget;
  75563. }
  75564. /** @hidden */
  75565. export interface IGLTFAnimationSampler {
  75566. input: string;
  75567. output: string;
  75568. interpolation?: string;
  75569. }
  75570. /** @hidden */
  75571. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75572. channels?: IGLTFAnimationChannel[];
  75573. parameters?: {
  75574. [key: string]: string;
  75575. };
  75576. samplers?: {
  75577. [key: string]: IGLTFAnimationSampler;
  75578. };
  75579. }
  75580. /** @hidden */
  75581. export interface IGLTFNodeInstanceSkin {
  75582. skeletons: string[];
  75583. skin: string;
  75584. meshes: string[];
  75585. }
  75586. /** @hidden */
  75587. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75588. bindShapeMatrix: number[];
  75589. inverseBindMatrices: string;
  75590. jointNames: string[];
  75591. babylonSkeleton?: Skeleton;
  75592. }
  75593. /** @hidden */
  75594. export interface IGLTFNode extends IGLTFChildRootProperty {
  75595. camera?: string;
  75596. children: string[];
  75597. skin?: string;
  75598. jointName?: string;
  75599. light?: string;
  75600. matrix: number[];
  75601. mesh?: string;
  75602. meshes?: string[];
  75603. rotation?: number[];
  75604. scale?: number[];
  75605. translation?: number[];
  75606. babylonNode?: Node;
  75607. }
  75608. /** @hidden */
  75609. export interface IGLTFScene extends IGLTFChildRootProperty {
  75610. nodes: string[];
  75611. }
  75612. /** @hidden */
  75613. export interface IGLTFRuntime {
  75614. extensions: {
  75615. [key: string]: any;
  75616. };
  75617. accessors: {
  75618. [key: string]: IGLTFAccessor;
  75619. };
  75620. buffers: {
  75621. [key: string]: IGLTFBuffer;
  75622. };
  75623. bufferViews: {
  75624. [key: string]: IGLTFBufferView;
  75625. };
  75626. meshes: {
  75627. [key: string]: IGLTFMesh;
  75628. };
  75629. lights: {
  75630. [key: string]: IGLTFLight;
  75631. };
  75632. cameras: {
  75633. [key: string]: IGLTFCamera;
  75634. };
  75635. nodes: {
  75636. [key: string]: IGLTFNode;
  75637. };
  75638. images: {
  75639. [key: string]: IGLTFImage;
  75640. };
  75641. textures: {
  75642. [key: string]: IGLTFTexture;
  75643. };
  75644. shaders: {
  75645. [key: string]: IGLTFShader;
  75646. };
  75647. programs: {
  75648. [key: string]: IGLTFProgram;
  75649. };
  75650. samplers: {
  75651. [key: string]: IGLTFSampler;
  75652. };
  75653. techniques: {
  75654. [key: string]: IGLTFTechnique;
  75655. };
  75656. materials: {
  75657. [key: string]: IGLTFMaterial;
  75658. };
  75659. animations: {
  75660. [key: string]: IGLTFAnimation;
  75661. };
  75662. skins: {
  75663. [key: string]: IGLTFSkins;
  75664. };
  75665. currentScene?: Object;
  75666. scenes: {
  75667. [key: string]: IGLTFScene;
  75668. };
  75669. extensionsUsed: string[];
  75670. extensionsRequired?: string[];
  75671. buffersCount: number;
  75672. shaderscount: number;
  75673. scene: Scene;
  75674. rootUrl: string;
  75675. loadedBufferCount: number;
  75676. loadedBufferViews: {
  75677. [name: string]: ArrayBufferView;
  75678. };
  75679. loadedShaderCount: number;
  75680. importOnlyMeshes: boolean;
  75681. importMeshesNames?: string[];
  75682. dummyNodes: Node[];
  75683. forAssetContainer: boolean;
  75684. }
  75685. /** @hidden */
  75686. export interface INodeToRoot {
  75687. bone: Bone;
  75688. node: IGLTFNode;
  75689. id: string;
  75690. }
  75691. /** @hidden */
  75692. export interface IJointNode {
  75693. node: IGLTFNode;
  75694. id: string;
  75695. }
  75696. }
  75697. declare module BABYLON.GLTF1 {
  75698. /**
  75699. * Utils functions for GLTF
  75700. * @hidden
  75701. */
  75702. export class GLTFUtils {
  75703. /**
  75704. * Sets the given "parameter" matrix
  75705. * @param scene: the Scene object
  75706. * @param source: the source node where to pick the matrix
  75707. * @param parameter: the GLTF technique parameter
  75708. * @param uniformName: the name of the shader's uniform
  75709. * @param shaderMaterial: the shader material
  75710. */
  75711. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75712. /**
  75713. * Sets the given "parameter" matrix
  75714. * @param shaderMaterial: the shader material
  75715. * @param uniform: the name of the shader's uniform
  75716. * @param value: the value of the uniform
  75717. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75718. */
  75719. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75720. /**
  75721. * Returns the wrap mode of the texture
  75722. * @param mode: the mode value
  75723. */
  75724. static GetWrapMode(mode: number): number;
  75725. /**
  75726. * Returns the byte stride giving an accessor
  75727. * @param accessor: the GLTF accessor objet
  75728. */
  75729. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75730. /**
  75731. * Returns the texture filter mode giving a mode value
  75732. * @param mode: the filter mode value
  75733. */
  75734. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75735. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75736. /**
  75737. * Returns a buffer from its accessor
  75738. * @param gltfRuntime: the GLTF runtime
  75739. * @param accessor: the GLTF accessor
  75740. */
  75741. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75742. /**
  75743. * Decodes a buffer view into a string
  75744. * @param view: the buffer view
  75745. */
  75746. static DecodeBufferToText(view: ArrayBufferView): string;
  75747. /**
  75748. * Returns the default material of gltf. Related to
  75749. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75750. * @param scene: the Babylon.js scene
  75751. */
  75752. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75753. private static _DefaultMaterial;
  75754. }
  75755. }
  75756. declare module BABYLON.GLTF1 {
  75757. /**
  75758. * Implementation of the base glTF spec
  75759. * @hidden
  75760. */
  75761. export class GLTFLoaderBase {
  75762. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75763. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75764. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75765. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75766. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75767. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75768. }
  75769. /**
  75770. * glTF V1 Loader
  75771. * @hidden
  75772. */
  75773. export class GLTFLoader implements IGLTFLoader {
  75774. static Extensions: {
  75775. [name: string]: GLTFLoaderExtension;
  75776. };
  75777. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75778. state: Nullable<GLTFLoaderState>;
  75779. dispose(): void;
  75780. private _importMeshAsync;
  75781. /**
  75782. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75783. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75784. * @param scene the scene the meshes should be added to
  75785. * @param forAssetContainer defines if the entities must be stored in the scene
  75786. * @param data gltf data containing information of the meshes in a loaded file
  75787. * @param rootUrl root url to load from
  75788. * @param onProgress event that fires when loading progress has occured
  75789. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75790. */
  75791. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75792. private _loadAsync;
  75793. /**
  75794. * Imports all objects from a loaded gltf file and adds them to the scene
  75795. * @param scene the scene the objects should be added to
  75796. * @param data gltf data containing information of the meshes in a loaded file
  75797. * @param rootUrl root url to load from
  75798. * @param onProgress event that fires when loading progress has occured
  75799. * @returns a promise which completes when objects have been loaded to the scene
  75800. */
  75801. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75802. private _loadShadersAsync;
  75803. private _loadBuffersAsync;
  75804. private _createNodes;
  75805. }
  75806. /** @hidden */
  75807. export abstract class GLTFLoaderExtension {
  75808. private _name;
  75809. constructor(name: string);
  75810. get name(): string;
  75811. /**
  75812. * Defines an override for loading the runtime
  75813. * Return true to stop further extensions from loading the runtime
  75814. */
  75815. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75816. /**
  75817. * Defines an onverride for creating gltf runtime
  75818. * Return true to stop further extensions from creating the runtime
  75819. */
  75820. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75821. /**
  75822. * Defines an override for loading buffers
  75823. * Return true to stop further extensions from loading this buffer
  75824. */
  75825. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75826. /**
  75827. * Defines an override for loading texture buffers
  75828. * Return true to stop further extensions from loading this texture data
  75829. */
  75830. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75831. /**
  75832. * Defines an override for creating textures
  75833. * Return true to stop further extensions from loading this texture
  75834. */
  75835. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75836. /**
  75837. * Defines an override for loading shader strings
  75838. * Return true to stop further extensions from loading this shader data
  75839. */
  75840. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75841. /**
  75842. * Defines an override for loading materials
  75843. * Return true to stop further extensions from loading this material
  75844. */
  75845. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75846. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75847. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75848. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75849. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75850. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75851. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75852. private static LoadTextureBufferAsync;
  75853. private static CreateTextureAsync;
  75854. private static ApplyExtensions;
  75855. }
  75856. }
  75857. declare module BABYLON.GLTF1 {
  75858. /** @hidden */
  75859. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75860. private _bin;
  75861. constructor();
  75862. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75863. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75864. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75865. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75866. }
  75867. }
  75868. declare module BABYLON.GLTF1 {
  75869. /** @hidden */
  75870. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75871. constructor();
  75872. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75873. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75874. private _loadTexture;
  75875. }
  75876. }
  75877. declare module BABYLON.GLTF2.Loader {
  75878. /**
  75879. * Loader interface with an index field.
  75880. */
  75881. export interface IArrayItem {
  75882. /**
  75883. * The index of this item in the array.
  75884. */
  75885. index: number;
  75886. }
  75887. /**
  75888. * Loader interface with additional members.
  75889. */
  75890. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75891. /** @hidden */
  75892. _data?: Promise<ArrayBufferView>;
  75893. /** @hidden */
  75894. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75895. }
  75896. /**
  75897. * Loader interface with additional members.
  75898. */
  75899. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75900. }
  75901. /** @hidden */
  75902. export interface _IAnimationSamplerData {
  75903. input: Float32Array;
  75904. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75905. output: Float32Array;
  75906. }
  75907. /**
  75908. * Loader interface with additional members.
  75909. */
  75910. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75911. /** @hidden */
  75912. _data?: Promise<_IAnimationSamplerData>;
  75913. }
  75914. /**
  75915. * Loader interface with additional members.
  75916. */
  75917. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75918. channels: IAnimationChannel[];
  75919. samplers: IAnimationSampler[];
  75920. /** @hidden */
  75921. _babylonAnimationGroup?: AnimationGroup;
  75922. }
  75923. /**
  75924. * Loader interface with additional members.
  75925. */
  75926. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75927. /** @hidden */
  75928. _data?: Promise<ArrayBufferView>;
  75929. }
  75930. /**
  75931. * Loader interface with additional members.
  75932. */
  75933. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75934. /** @hidden */
  75935. _data?: Promise<ArrayBufferView>;
  75936. /** @hidden */
  75937. _babylonBuffer?: Promise<Buffer>;
  75938. }
  75939. /**
  75940. * Loader interface with additional members.
  75941. */
  75942. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75943. }
  75944. /**
  75945. * Loader interface with additional members.
  75946. */
  75947. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75948. /** @hidden */
  75949. _data?: Promise<ArrayBufferView>;
  75950. }
  75951. /**
  75952. * Loader interface with additional members.
  75953. */
  75954. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75955. }
  75956. /**
  75957. * Loader interface with additional members.
  75958. */
  75959. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75960. }
  75961. /**
  75962. * Loader interface with additional members.
  75963. */
  75964. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75965. baseColorTexture?: ITextureInfo;
  75966. metallicRoughnessTexture?: ITextureInfo;
  75967. }
  75968. /**
  75969. * Loader interface with additional members.
  75970. */
  75971. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75972. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75973. normalTexture?: IMaterialNormalTextureInfo;
  75974. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75975. emissiveTexture?: ITextureInfo;
  75976. /** @hidden */
  75977. _data?: {
  75978. [babylonDrawMode: number]: {
  75979. babylonMaterial: Material;
  75980. babylonMeshes: AbstractMesh[];
  75981. promise: Promise<void>;
  75982. };
  75983. };
  75984. }
  75985. /**
  75986. * Loader interface with additional members.
  75987. */
  75988. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75989. primitives: IMeshPrimitive[];
  75990. }
  75991. /**
  75992. * Loader interface with additional members.
  75993. */
  75994. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75995. /** @hidden */
  75996. _instanceData?: {
  75997. babylonSourceMesh: Mesh;
  75998. promise: Promise<any>;
  75999. };
  76000. }
  76001. /**
  76002. * Loader interface with additional members.
  76003. */
  76004. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76005. /**
  76006. * The parent glTF node.
  76007. */
  76008. parent?: INode;
  76009. /** @hidden */
  76010. _babylonTransformNode?: TransformNode;
  76011. /** @hidden */
  76012. _primitiveBabylonMeshes?: AbstractMesh[];
  76013. /** @hidden */
  76014. _babylonBones?: Bone[];
  76015. /** @hidden */
  76016. _numMorphTargets?: number;
  76017. }
  76018. /** @hidden */
  76019. export interface _ISamplerData {
  76020. noMipMaps: boolean;
  76021. samplingMode: number;
  76022. wrapU: number;
  76023. wrapV: number;
  76024. }
  76025. /**
  76026. * Loader interface with additional members.
  76027. */
  76028. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76029. /** @hidden */
  76030. _data?: _ISamplerData;
  76031. }
  76032. /**
  76033. * Loader interface with additional members.
  76034. */
  76035. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76036. }
  76037. /**
  76038. * Loader interface with additional members.
  76039. */
  76040. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76041. /** @hidden */
  76042. _data?: {
  76043. babylonSkeleton: Skeleton;
  76044. promise: Promise<void>;
  76045. };
  76046. }
  76047. /**
  76048. * Loader interface with additional members.
  76049. */
  76050. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76051. }
  76052. /**
  76053. * Loader interface with additional members.
  76054. */
  76055. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76056. }
  76057. /**
  76058. * Loader interface with additional members.
  76059. */
  76060. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76061. accessors?: IAccessor[];
  76062. animations?: IAnimation[];
  76063. buffers?: IBuffer[];
  76064. bufferViews?: IBufferView[];
  76065. cameras?: ICamera[];
  76066. images?: IImage[];
  76067. materials?: IMaterial[];
  76068. meshes?: IMesh[];
  76069. nodes?: INode[];
  76070. samplers?: ISampler[];
  76071. scenes?: IScene[];
  76072. skins?: ISkin[];
  76073. textures?: ITexture[];
  76074. }
  76075. }
  76076. declare module BABYLON.GLTF2 {
  76077. /**
  76078. * Interface for a glTF loader extension.
  76079. */
  76080. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76081. /**
  76082. * Called after the loader state changes to LOADING.
  76083. */
  76084. onLoading?(): void;
  76085. /**
  76086. * Called after the loader state changes to READY.
  76087. */
  76088. onReady?(): void;
  76089. /**
  76090. * Define this method to modify the default behavior when loading scenes.
  76091. * @param context The context when loading the asset
  76092. * @param scene The glTF scene property
  76093. * @returns A promise that resolves when the load is complete or null if not handled
  76094. */
  76095. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76096. /**
  76097. * Define this method to modify the default behavior when loading nodes.
  76098. * @param context The context when loading the asset
  76099. * @param node The glTF node property
  76100. * @param assign A function called synchronously after parsing the glTF properties
  76101. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76102. */
  76103. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76104. /**
  76105. * Define this method to modify the default behavior when loading cameras.
  76106. * @param context The context when loading the asset
  76107. * @param camera The glTF camera property
  76108. * @param assign A function called synchronously after parsing the glTF properties
  76109. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76110. */
  76111. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76112. /**
  76113. * @hidden
  76114. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76115. * @param context The context when loading the asset
  76116. * @param primitive The glTF mesh primitive property
  76117. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76118. */
  76119. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76120. /**
  76121. * @hidden
  76122. * Define this method to modify the default behavior when loading data for mesh primitives.
  76123. * @param context The context when loading the asset
  76124. * @param name The mesh name when loading the asset
  76125. * @param node The glTF node when loading the asset
  76126. * @param mesh The glTF mesh when loading the asset
  76127. * @param primitive The glTF mesh primitive property
  76128. * @param assign A function called synchronously after parsing the glTF properties
  76129. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76130. */
  76131. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76132. /**
  76133. * @hidden
  76134. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76135. * @param context The context when loading the asset
  76136. * @param material The glTF material property
  76137. * @param assign A function called synchronously after parsing the glTF properties
  76138. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76139. */
  76140. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76141. /**
  76142. * Define this method to modify the default behavior when creating materials.
  76143. * @param context The context when loading the asset
  76144. * @param material The glTF material property
  76145. * @param babylonDrawMode The draw mode for the Babylon material
  76146. * @returns The Babylon material or null if not handled
  76147. */
  76148. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76149. /**
  76150. * Define this method to modify the default behavior when loading material properties.
  76151. * @param context The context when loading the asset
  76152. * @param material The glTF material property
  76153. * @param babylonMaterial The Babylon material
  76154. * @returns A promise that resolves when the load is complete or null if not handled
  76155. */
  76156. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76157. /**
  76158. * Define this method to modify the default behavior when loading texture infos.
  76159. * @param context The context when loading the asset
  76160. * @param textureInfo The glTF texture info property
  76161. * @param assign A function called synchronously after parsing the glTF properties
  76162. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76163. */
  76164. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76165. /**
  76166. * @hidden
  76167. * Define this method to modify the default behavior when loading textures.
  76168. * @param context The context when loading the asset
  76169. * @param texture The glTF texture property
  76170. * @param assign A function called synchronously after parsing the glTF properties
  76171. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76172. */
  76173. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76174. /**
  76175. * Define this method to modify the default behavior when loading animations.
  76176. * @param context The context when loading the asset
  76177. * @param animation The glTF animation property
  76178. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76179. */
  76180. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76181. /**
  76182. * @hidden
  76183. * Define this method to modify the default behavior when loading skins.
  76184. * @param context The context when loading the asset
  76185. * @param node The glTF node property
  76186. * @param skin The glTF skin property
  76187. * @returns A promise that resolves when the load is complete or null if not handled
  76188. */
  76189. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76190. /**
  76191. * @hidden
  76192. * Define this method to modify the default behavior when loading uris.
  76193. * @param context The context when loading the asset
  76194. * @param property The glTF property associated with the uri
  76195. * @param uri The uri to load
  76196. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76197. */
  76198. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76199. /**
  76200. * Define this method to modify the default behavior when loading buffer views.
  76201. * @param context The context when loading the asset
  76202. * @param bufferView The glTF buffer view property
  76203. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76204. */
  76205. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76206. /**
  76207. * Define this method to modify the default behavior when loading buffers.
  76208. * @param context The context when loading the asset
  76209. * @param buffer The glTF buffer property
  76210. * @param byteOffset The byte offset to load
  76211. * @param byteLength The byte length to load
  76212. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76213. */
  76214. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76215. }
  76216. }
  76217. declare module BABYLON.GLTF2 {
  76218. /**
  76219. * Helper class for working with arrays when loading the glTF asset
  76220. */
  76221. export class ArrayItem {
  76222. /**
  76223. * Gets an item from the given array.
  76224. * @param context The context when loading the asset
  76225. * @param array The array to get the item from
  76226. * @param index The index to the array
  76227. * @returns The array item
  76228. */
  76229. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76230. /**
  76231. * Assign an `index` field to each item of the given array.
  76232. * @param array The array of items
  76233. */
  76234. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76235. }
  76236. /**
  76237. * The glTF 2.0 loader
  76238. */
  76239. export class GLTFLoader implements IGLTFLoader {
  76240. /** @hidden */
  76241. _completePromises: Promise<any>[];
  76242. /** @hidden */
  76243. _forAssetContainer: boolean;
  76244. /** Storage */
  76245. _babylonLights: Light[];
  76246. private _disposed;
  76247. private _parent;
  76248. private _state;
  76249. private _extensions;
  76250. private _rootUrl;
  76251. private _fileName;
  76252. private _uniqueRootUrl;
  76253. private _gltf;
  76254. private _bin;
  76255. private _babylonScene;
  76256. private _rootBabylonMesh;
  76257. private _defaultBabylonMaterialData;
  76258. private _progressCallback?;
  76259. private _requests;
  76260. private static _RegisteredExtensions;
  76261. /**
  76262. * The default glTF sampler.
  76263. */
  76264. static readonly DefaultSampler: ISampler;
  76265. /**
  76266. * Registers a loader extension.
  76267. * @param name The name of the loader extension.
  76268. * @param factory The factory function that creates the loader extension.
  76269. */
  76270. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76271. /**
  76272. * Unregisters a loader extension.
  76273. * @param name The name of the loader extension.
  76274. * @returns A boolean indicating whether the extension has been unregistered
  76275. */
  76276. static UnregisterExtension(name: string): boolean;
  76277. /**
  76278. * The loader state.
  76279. */
  76280. get state(): Nullable<GLTFLoaderState>;
  76281. /**
  76282. * The object that represents the glTF JSON.
  76283. */
  76284. get gltf(): IGLTF;
  76285. /**
  76286. * The BIN chunk of a binary glTF.
  76287. */
  76288. get bin(): Nullable<IDataBuffer>;
  76289. /**
  76290. * The parent file loader.
  76291. */
  76292. get parent(): GLTFFileLoader;
  76293. /**
  76294. * The Babylon scene when loading the asset.
  76295. */
  76296. get babylonScene(): Scene;
  76297. /**
  76298. * The root Babylon mesh when loading the asset.
  76299. */
  76300. get rootBabylonMesh(): Mesh;
  76301. /** @hidden */
  76302. constructor(parent: GLTFFileLoader);
  76303. /** @hidden */
  76304. dispose(): void;
  76305. /** @hidden */
  76306. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76307. /** @hidden */
  76308. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76309. private _loadAsync;
  76310. private _loadData;
  76311. private _setupData;
  76312. private _loadExtensions;
  76313. private _checkExtensions;
  76314. private _setState;
  76315. private _createRootNode;
  76316. /**
  76317. * Loads a glTF scene.
  76318. * @param context The context when loading the asset
  76319. * @param scene The glTF scene property
  76320. * @returns A promise that resolves when the load is complete
  76321. */
  76322. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76323. private _forEachPrimitive;
  76324. private _getMeshes;
  76325. private _getTransformNodes;
  76326. private _getSkeletons;
  76327. private _getAnimationGroups;
  76328. private _startAnimations;
  76329. /**
  76330. * Loads a glTF node.
  76331. * @param context The context when loading the asset
  76332. * @param node The glTF node property
  76333. * @param assign A function called synchronously after parsing the glTF properties
  76334. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76335. */
  76336. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76337. private _loadMeshAsync;
  76338. /**
  76339. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76340. * @param context The context when loading the asset
  76341. * @param name The mesh name when loading the asset
  76342. * @param node The glTF node when loading the asset
  76343. * @param mesh The glTF mesh when loading the asset
  76344. * @param primitive The glTF mesh primitive property
  76345. * @param assign A function called synchronously after parsing the glTF properties
  76346. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76347. */
  76348. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76349. private _loadVertexDataAsync;
  76350. private _createMorphTargets;
  76351. private _loadMorphTargetsAsync;
  76352. private _loadMorphTargetVertexDataAsync;
  76353. private static _LoadTransform;
  76354. private _loadSkinAsync;
  76355. private _loadBones;
  76356. private _loadBone;
  76357. private _loadSkinInverseBindMatricesDataAsync;
  76358. private _updateBoneMatrices;
  76359. private _getNodeMatrix;
  76360. /**
  76361. * Loads a glTF camera.
  76362. * @param context The context when loading the asset
  76363. * @param camera The glTF camera property
  76364. * @param assign A function called synchronously after parsing the glTF properties
  76365. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76366. */
  76367. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76368. private _loadAnimationsAsync;
  76369. /**
  76370. * Loads a glTF animation.
  76371. * @param context The context when loading the asset
  76372. * @param animation The glTF animation property
  76373. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76374. */
  76375. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76376. /**
  76377. * @hidden Loads a glTF animation channel.
  76378. * @param context The context when loading the asset
  76379. * @param animationContext The context of the animation when loading the asset
  76380. * @param animation The glTF animation property
  76381. * @param channel The glTF animation channel property
  76382. * @param babylonAnimationGroup The babylon animation group property
  76383. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76384. * @returns A void promise when the channel load is complete
  76385. */
  76386. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76387. private _loadAnimationSamplerAsync;
  76388. private _loadBufferAsync;
  76389. /**
  76390. * Loads a glTF buffer view.
  76391. * @param context The context when loading the asset
  76392. * @param bufferView The glTF buffer view property
  76393. * @returns A promise that resolves with the loaded data when the load is complete
  76394. */
  76395. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76396. private _loadAccessorAsync;
  76397. /** @hidden */
  76398. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76399. private _loadIndicesAccessorAsync;
  76400. private _loadVertexBufferViewAsync;
  76401. private _loadVertexAccessorAsync;
  76402. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76403. /** @hidden */
  76404. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76405. private _createDefaultMaterial;
  76406. /**
  76407. * Creates a Babylon material from a glTF material.
  76408. * @param context The context when loading the asset
  76409. * @param material The glTF material property
  76410. * @param babylonDrawMode The draw mode for the Babylon material
  76411. * @returns The Babylon material
  76412. */
  76413. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76414. /**
  76415. * Loads properties from a glTF material into a Babylon material.
  76416. * @param context The context when loading the asset
  76417. * @param material The glTF material property
  76418. * @param babylonMaterial The Babylon material
  76419. * @returns A promise that resolves when the load is complete
  76420. */
  76421. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76422. /**
  76423. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76424. * @param context The context when loading the asset
  76425. * @param material The glTF material property
  76426. * @param babylonMaterial The Babylon material
  76427. * @returns A promise that resolves when the load is complete
  76428. */
  76429. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76430. /**
  76431. * Loads the alpha properties from a glTF material into a Babylon material.
  76432. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76433. * @param context The context when loading the asset
  76434. * @param material The glTF material property
  76435. * @param babylonMaterial The Babylon material
  76436. */
  76437. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76438. /**
  76439. * Loads a glTF texture info.
  76440. * @param context The context when loading the asset
  76441. * @param textureInfo The glTF texture info property
  76442. * @param assign A function called synchronously after parsing the glTF properties
  76443. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76444. */
  76445. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76446. /** @hidden */
  76447. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76448. /** @hidden */
  76449. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76450. private _loadSampler;
  76451. /**
  76452. * Loads a glTF image.
  76453. * @param context The context when loading the asset
  76454. * @param image The glTF image property
  76455. * @returns A promise that resolves with the loaded data when the load is complete
  76456. */
  76457. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76458. /**
  76459. * Loads a glTF uri.
  76460. * @param context The context when loading the asset
  76461. * @param property The glTF property associated with the uri
  76462. * @param uri The base64 or relative uri
  76463. * @returns A promise that resolves with the loaded data when the load is complete
  76464. */
  76465. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76466. private _onProgress;
  76467. /**
  76468. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76469. * @param babylonObject the Babylon object with metadata
  76470. * @param pointer the JSON pointer
  76471. */
  76472. static AddPointerMetadata(babylonObject: {
  76473. metadata: any;
  76474. }, pointer: string): void;
  76475. private static _GetTextureWrapMode;
  76476. private static _GetTextureSamplingMode;
  76477. private static _GetTypedArrayConstructor;
  76478. private static _GetTypedArray;
  76479. private static _GetNumComponents;
  76480. private static _ValidateUri;
  76481. private static _GetDrawMode;
  76482. private _compileMaterialsAsync;
  76483. private _compileShadowGeneratorsAsync;
  76484. private _forEachExtensions;
  76485. private _applyExtensions;
  76486. private _extensionsOnLoading;
  76487. private _extensionsOnReady;
  76488. private _extensionsLoadSceneAsync;
  76489. private _extensionsLoadNodeAsync;
  76490. private _extensionsLoadCameraAsync;
  76491. private _extensionsLoadVertexDataAsync;
  76492. private _extensionsLoadMeshPrimitiveAsync;
  76493. private _extensionsLoadMaterialAsync;
  76494. private _extensionsCreateMaterial;
  76495. private _extensionsLoadMaterialPropertiesAsync;
  76496. private _extensionsLoadTextureInfoAsync;
  76497. private _extensionsLoadTextureAsync;
  76498. private _extensionsLoadAnimationAsync;
  76499. private _extensionsLoadSkinAsync;
  76500. private _extensionsLoadUriAsync;
  76501. private _extensionsLoadBufferViewAsync;
  76502. private _extensionsLoadBufferAsync;
  76503. /**
  76504. * Helper method called by a loader extension to load an glTF extension.
  76505. * @param context The context when loading the asset
  76506. * @param property The glTF property to load the extension from
  76507. * @param extensionName The name of the extension to load
  76508. * @param actionAsync The action to run
  76509. * @returns The promise returned by actionAsync or null if the extension does not exist
  76510. */
  76511. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76512. /**
  76513. * Helper method called by a loader extension to load a glTF extra.
  76514. * @param context The context when loading the asset
  76515. * @param property The glTF property to load the extra from
  76516. * @param extensionName The name of the extension to load
  76517. * @param actionAsync The action to run
  76518. * @returns The promise returned by actionAsync or null if the extra does not exist
  76519. */
  76520. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76521. /**
  76522. * Checks for presence of an extension.
  76523. * @param name The name of the extension to check
  76524. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76525. */
  76526. isExtensionUsed(name: string): boolean;
  76527. /**
  76528. * Increments the indentation level and logs a message.
  76529. * @param message The message to log
  76530. */
  76531. logOpen(message: string): void;
  76532. /**
  76533. * Decrements the indentation level.
  76534. */
  76535. logClose(): void;
  76536. /**
  76537. * Logs a message
  76538. * @param message The message to log
  76539. */
  76540. log(message: string): void;
  76541. /**
  76542. * Starts a performance counter.
  76543. * @param counterName The name of the performance counter
  76544. */
  76545. startPerformanceCounter(counterName: string): void;
  76546. /**
  76547. * Ends a performance counter.
  76548. * @param counterName The name of the performance counter
  76549. */
  76550. endPerformanceCounter(counterName: string): void;
  76551. }
  76552. }
  76553. declare module BABYLON.GLTF2.Loader.Extensions {
  76554. /**
  76555. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76556. */
  76557. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76558. /**
  76559. * The name of this extension.
  76560. */
  76561. readonly name: string;
  76562. /**
  76563. * Defines whether this extension is enabled.
  76564. */
  76565. enabled: boolean;
  76566. private _loader;
  76567. private _lights?;
  76568. /** @hidden */
  76569. constructor(loader: GLTFLoader);
  76570. /** @hidden */
  76571. dispose(): void;
  76572. /** @hidden */
  76573. onLoading(): void;
  76574. /** @hidden */
  76575. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76576. private _loadLightAsync;
  76577. }
  76578. }
  76579. declare module BABYLON.GLTF2.Loader.Extensions {
  76580. /**
  76581. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76582. */
  76583. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76584. /**
  76585. * The name of this extension.
  76586. */
  76587. readonly name: string;
  76588. /**
  76589. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76590. */
  76591. dracoCompression?: DracoCompression;
  76592. /**
  76593. * Defines whether this extension is enabled.
  76594. */
  76595. enabled: boolean;
  76596. private _loader;
  76597. /** @hidden */
  76598. constructor(loader: GLTFLoader);
  76599. /** @hidden */
  76600. dispose(): void;
  76601. /** @hidden */
  76602. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76603. }
  76604. }
  76605. declare module BABYLON.GLTF2.Loader.Extensions {
  76606. /**
  76607. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76608. */
  76609. export class KHR_lights implements IGLTFLoaderExtension {
  76610. /**
  76611. * The name of this extension.
  76612. */
  76613. readonly name: string;
  76614. /**
  76615. * Defines whether this extension is enabled.
  76616. */
  76617. enabled: boolean;
  76618. private _loader;
  76619. private _lights?;
  76620. /** @hidden */
  76621. constructor(loader: GLTFLoader);
  76622. /** @hidden */
  76623. dispose(): void;
  76624. /** @hidden */
  76625. onLoading(): void;
  76626. /** @hidden */
  76627. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76628. }
  76629. }
  76630. declare module BABYLON.GLTF2.Loader.Extensions {
  76631. /**
  76632. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76633. */
  76634. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76635. /**
  76636. * The name of this extension.
  76637. */
  76638. readonly name: string;
  76639. /**
  76640. * Defines whether this extension is enabled.
  76641. */
  76642. enabled: boolean;
  76643. /**
  76644. * Defines a number that determines the order the extensions are applied.
  76645. */
  76646. order: number;
  76647. private _loader;
  76648. /** @hidden */
  76649. constructor(loader: GLTFLoader);
  76650. /** @hidden */
  76651. dispose(): void;
  76652. /** @hidden */
  76653. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76654. private _loadSpecularGlossinessPropertiesAsync;
  76655. }
  76656. }
  76657. declare module BABYLON.GLTF2.Loader.Extensions {
  76658. /**
  76659. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76660. */
  76661. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76662. /**
  76663. * The name of this extension.
  76664. */
  76665. readonly name: string;
  76666. /**
  76667. * Defines whether this extension is enabled.
  76668. */
  76669. enabled: boolean;
  76670. /**
  76671. * Defines a number that determines the order the extensions are applied.
  76672. */
  76673. order: number;
  76674. private _loader;
  76675. /** @hidden */
  76676. constructor(loader: GLTFLoader);
  76677. /** @hidden */
  76678. dispose(): void;
  76679. /** @hidden */
  76680. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76681. private _loadUnlitPropertiesAsync;
  76682. }
  76683. }
  76684. declare module BABYLON.GLTF2.Loader.Extensions {
  76685. /**
  76686. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76687. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76688. * !!! Experimental Extension Subject to Changes !!!
  76689. */
  76690. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76691. /**
  76692. * The name of this extension.
  76693. */
  76694. readonly name: string;
  76695. /**
  76696. * Defines whether this extension is enabled.
  76697. */
  76698. enabled: boolean;
  76699. /**
  76700. * Defines a number that determines the order the extensions are applied.
  76701. */
  76702. order: number;
  76703. private _loader;
  76704. /** @hidden */
  76705. constructor(loader: GLTFLoader);
  76706. /** @hidden */
  76707. dispose(): void;
  76708. /** @hidden */
  76709. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76710. private _loadClearCoatPropertiesAsync;
  76711. }
  76712. }
  76713. declare module BABYLON.GLTF2.Loader.Extensions {
  76714. /**
  76715. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76716. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76717. * !!! Experimental Extension Subject to Changes !!!
  76718. */
  76719. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76720. /**
  76721. * The name of this extension.
  76722. */
  76723. readonly name: string;
  76724. /**
  76725. * Defines whether this extension is enabled.
  76726. */
  76727. enabled: boolean;
  76728. /**
  76729. * Defines a number that determines the order the extensions are applied.
  76730. */
  76731. order: number;
  76732. private _loader;
  76733. /** @hidden */
  76734. constructor(loader: GLTFLoader);
  76735. /** @hidden */
  76736. dispose(): void;
  76737. /** @hidden */
  76738. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76739. private _loadSheenPropertiesAsync;
  76740. }
  76741. }
  76742. declare module BABYLON.GLTF2.Loader.Extensions {
  76743. /**
  76744. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76745. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76746. * !!! Experimental Extension Subject to Changes !!!
  76747. */
  76748. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76749. /**
  76750. * The name of this extension.
  76751. */
  76752. readonly name: string;
  76753. /**
  76754. * Defines whether this extension is enabled.
  76755. */
  76756. enabled: boolean;
  76757. /**
  76758. * Defines a number that determines the order the extensions are applied.
  76759. */
  76760. order: number;
  76761. private _loader;
  76762. /** @hidden */
  76763. constructor(loader: GLTFLoader);
  76764. /** @hidden */
  76765. dispose(): void;
  76766. /** @hidden */
  76767. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76768. private _loadSpecularPropertiesAsync;
  76769. }
  76770. }
  76771. declare module BABYLON.GLTF2.Loader.Extensions {
  76772. /**
  76773. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76774. * [Playground Sample](//TODO)
  76775. * !!! Experimental Extension Subject to Changes !!!
  76776. */
  76777. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76778. /**
  76779. * The name of this extension.
  76780. */
  76781. readonly name: string;
  76782. /**
  76783. * Defines whether this extension is enabled.
  76784. */
  76785. enabled: boolean;
  76786. private _loader;
  76787. /** @hidden */
  76788. constructor(loader: GLTFLoader);
  76789. /** @hidden */
  76790. dispose(): void;
  76791. /** @hidden */
  76792. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76793. }
  76794. }
  76795. declare module BABYLON.GLTF2.Loader.Extensions {
  76796. /**
  76797. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76798. */
  76799. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76800. /**
  76801. * The name of this extension.
  76802. */
  76803. readonly name: string;
  76804. /**
  76805. * Defines whether this extension is enabled.
  76806. */
  76807. enabled: boolean;
  76808. /** @hidden */
  76809. constructor(loader: GLTFLoader);
  76810. /** @hidden */
  76811. dispose(): void;
  76812. }
  76813. }
  76814. declare module BABYLON.GLTF2.Loader.Extensions {
  76815. /**
  76816. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76817. * !!! Experimental Extension Subject to Changes !!!
  76818. */
  76819. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76820. /** The name of this extension. */
  76821. readonly name: string;
  76822. /** Defines whether this extension is enabled. */
  76823. enabled: boolean;
  76824. private _loader;
  76825. /** @hidden */
  76826. constructor(loader: GLTFLoader);
  76827. /** @hidden */
  76828. dispose(): void;
  76829. /** @hidden */
  76830. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76831. }
  76832. }
  76833. declare module BABYLON.GLTF2.Loader.Extensions {
  76834. /**
  76835. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76836. */
  76837. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76838. /**
  76839. * The name of this extension.
  76840. */
  76841. readonly name: string;
  76842. /**
  76843. * Defines whether this extension is enabled.
  76844. */
  76845. enabled: boolean;
  76846. private _loader;
  76847. /** @hidden */
  76848. constructor(loader: GLTFLoader);
  76849. /** @hidden */
  76850. dispose(): void;
  76851. /** @hidden */
  76852. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76853. }
  76854. }
  76855. declare module BABYLON.GLTF2.Loader.Extensions {
  76856. /**
  76857. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76858. */
  76859. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76860. /**
  76861. * The name of this extension.
  76862. */
  76863. readonly name: string;
  76864. /**
  76865. * Defines whether this extension is enabled.
  76866. */
  76867. enabled: boolean;
  76868. private _loader;
  76869. private _clips;
  76870. private _emitters;
  76871. /** @hidden */
  76872. constructor(loader: GLTFLoader);
  76873. /** @hidden */
  76874. dispose(): void;
  76875. /** @hidden */
  76876. onLoading(): void;
  76877. /** @hidden */
  76878. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76879. /** @hidden */
  76880. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76881. /** @hidden */
  76882. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76883. private _loadClipAsync;
  76884. private _loadEmitterAsync;
  76885. private _getEventAction;
  76886. private _loadAnimationEventAsync;
  76887. }
  76888. }
  76889. declare module BABYLON.GLTF2.Loader.Extensions {
  76890. /**
  76891. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76892. */
  76893. export class MSFT_lod implements IGLTFLoaderExtension {
  76894. /**
  76895. * The name of this extension.
  76896. */
  76897. readonly name: string;
  76898. /**
  76899. * Defines whether this extension is enabled.
  76900. */
  76901. enabled: boolean;
  76902. /**
  76903. * Defines a number that determines the order the extensions are applied.
  76904. */
  76905. order: number;
  76906. /**
  76907. * Maximum number of LODs to load, starting from the lowest LOD.
  76908. */
  76909. maxLODsToLoad: number;
  76910. /**
  76911. * Observable raised when all node LODs of one level are loaded.
  76912. * The event data is the index of the loaded LOD starting from zero.
  76913. * Dispose the loader to cancel the loading of the next level of LODs.
  76914. */
  76915. onNodeLODsLoadedObservable: Observable<number>;
  76916. /**
  76917. * Observable raised when all material LODs of one level are loaded.
  76918. * The event data is the index of the loaded LOD starting from zero.
  76919. * Dispose the loader to cancel the loading of the next level of LODs.
  76920. */
  76921. onMaterialLODsLoadedObservable: Observable<number>;
  76922. private _loader;
  76923. private _nodeIndexLOD;
  76924. private _nodeSignalLODs;
  76925. private _nodePromiseLODs;
  76926. private _materialIndexLOD;
  76927. private _materialSignalLODs;
  76928. private _materialPromiseLODs;
  76929. private _indexLOD;
  76930. private _bufferLODs;
  76931. /** @hidden */
  76932. constructor(loader: GLTFLoader);
  76933. /** @hidden */
  76934. dispose(): void;
  76935. /** @hidden */
  76936. onReady(): void;
  76937. /** @hidden */
  76938. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76939. /** @hidden */
  76940. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76941. /** @hidden */
  76942. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76943. /** @hidden */
  76944. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76945. /** @hidden */
  76946. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76947. private _loadBufferLOD;
  76948. /**
  76949. * Gets an array of LOD properties from lowest to highest.
  76950. */
  76951. private _getLODs;
  76952. private _disposeTransformNode;
  76953. private _disposeMaterials;
  76954. }
  76955. }
  76956. declare module BABYLON.GLTF2.Loader.Extensions {
  76957. /** @hidden */
  76958. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76959. readonly name: string;
  76960. enabled: boolean;
  76961. private _loader;
  76962. constructor(loader: GLTFLoader);
  76963. dispose(): void;
  76964. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76965. }
  76966. }
  76967. declare module BABYLON.GLTF2.Loader.Extensions {
  76968. /** @hidden */
  76969. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76970. readonly name: string;
  76971. enabled: boolean;
  76972. private _loader;
  76973. constructor(loader: GLTFLoader);
  76974. dispose(): void;
  76975. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76976. }
  76977. }
  76978. declare module BABYLON.GLTF2.Loader.Extensions {
  76979. /**
  76980. * Store glTF extras (if present) in BJS objects' metadata
  76981. */
  76982. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76983. /**
  76984. * The name of this extension.
  76985. */
  76986. readonly name: string;
  76987. /**
  76988. * Defines whether this extension is enabled.
  76989. */
  76990. enabled: boolean;
  76991. private _loader;
  76992. private _assignExtras;
  76993. /** @hidden */
  76994. constructor(loader: GLTFLoader);
  76995. /** @hidden */
  76996. dispose(): void;
  76997. /** @hidden */
  76998. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76999. /** @hidden */
  77000. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77001. /** @hidden */
  77002. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77003. }
  77004. }
  77005. declare module BABYLON {
  77006. /**
  77007. * Class reading and parsing the MTL file bundled with the obj file.
  77008. */
  77009. export class MTLFileLoader {
  77010. /**
  77011. * Invert Y-Axis of referenced textures on load
  77012. */
  77013. static INVERT_TEXTURE_Y: boolean;
  77014. /**
  77015. * All material loaded from the mtl will be set here
  77016. */
  77017. materials: StandardMaterial[];
  77018. /**
  77019. * This function will read the mtl file and create each material described inside
  77020. * This function could be improve by adding :
  77021. * -some component missing (Ni, Tf...)
  77022. * -including the specific options available
  77023. *
  77024. * @param scene defines the scene the material will be created in
  77025. * @param data defines the mtl data to parse
  77026. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77027. * @param forAssetContainer defines if the material should be registered in the scene
  77028. */
  77029. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77030. /**
  77031. * Gets the texture for the material.
  77032. *
  77033. * If the material is imported from input file,
  77034. * We sanitize the url to ensure it takes the textre from aside the material.
  77035. *
  77036. * @param rootUrl The root url to load from
  77037. * @param value The value stored in the mtl
  77038. * @return The Texture
  77039. */
  77040. private static _getTexture;
  77041. }
  77042. }
  77043. declare module BABYLON {
  77044. /**
  77045. * Options for loading OBJ/MTL files
  77046. */
  77047. type MeshLoadOptions = {
  77048. /**
  77049. * Defines if UVs are optimized by default during load.
  77050. */
  77051. OptimizeWithUV: boolean;
  77052. /**
  77053. * Defines custom scaling of UV coordinates of loaded meshes.
  77054. */
  77055. UVScaling: Vector2;
  77056. /**
  77057. * Invert model on y-axis (does a model scaling inversion)
  77058. */
  77059. InvertY: boolean;
  77060. /**
  77061. * Invert Y-Axis of referenced textures on load
  77062. */
  77063. InvertTextureY: boolean;
  77064. /**
  77065. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77066. */
  77067. ImportVertexColors: boolean;
  77068. /**
  77069. * Compute the normals for the model, even if normals are present in the file.
  77070. */
  77071. ComputeNormals: boolean;
  77072. /**
  77073. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77074. */
  77075. SkipMaterials: boolean;
  77076. /**
  77077. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77078. */
  77079. MaterialLoadingFailsSilently: boolean;
  77080. };
  77081. /**
  77082. * OBJ file type loader.
  77083. * This is a babylon scene loader plugin.
  77084. */
  77085. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77086. /**
  77087. * Defines if UVs are optimized by default during load.
  77088. */
  77089. static OPTIMIZE_WITH_UV: boolean;
  77090. /**
  77091. * Invert model on y-axis (does a model scaling inversion)
  77092. */
  77093. static INVERT_Y: boolean;
  77094. /**
  77095. * Invert Y-Axis of referenced textures on load
  77096. */
  77097. static get INVERT_TEXTURE_Y(): boolean;
  77098. static set INVERT_TEXTURE_Y(value: boolean);
  77099. /**
  77100. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77101. */
  77102. static IMPORT_VERTEX_COLORS: boolean;
  77103. /**
  77104. * Compute the normals for the model, even if normals are present in the file.
  77105. */
  77106. static COMPUTE_NORMALS: boolean;
  77107. /**
  77108. * Defines custom scaling of UV coordinates of loaded meshes.
  77109. */
  77110. static UV_SCALING: Vector2;
  77111. /**
  77112. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77113. */
  77114. static SKIP_MATERIALS: boolean;
  77115. /**
  77116. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77117. *
  77118. * Defaults to true for backwards compatibility.
  77119. */
  77120. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77121. /**
  77122. * Defines the name of the plugin.
  77123. */
  77124. name: string;
  77125. /**
  77126. * Defines the extension the plugin is able to load.
  77127. */
  77128. extensions: string;
  77129. /** @hidden */
  77130. obj: RegExp;
  77131. /** @hidden */
  77132. group: RegExp;
  77133. /** @hidden */
  77134. mtllib: RegExp;
  77135. /** @hidden */
  77136. usemtl: RegExp;
  77137. /** @hidden */
  77138. smooth: RegExp;
  77139. /** @hidden */
  77140. vertexPattern: RegExp;
  77141. /** @hidden */
  77142. normalPattern: RegExp;
  77143. /** @hidden */
  77144. uvPattern: RegExp;
  77145. /** @hidden */
  77146. facePattern1: RegExp;
  77147. /** @hidden */
  77148. facePattern2: RegExp;
  77149. /** @hidden */
  77150. facePattern3: RegExp;
  77151. /** @hidden */
  77152. facePattern4: RegExp;
  77153. /** @hidden */
  77154. facePattern5: RegExp;
  77155. private _forAssetContainer;
  77156. private _meshLoadOptions;
  77157. /**
  77158. * Creates loader for .OBJ files
  77159. *
  77160. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77161. */
  77162. constructor(meshLoadOptions?: MeshLoadOptions);
  77163. private static get currentMeshLoadOptions();
  77164. /**
  77165. * Calls synchronously the MTL file attached to this obj.
  77166. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77167. * Without this function materials are not displayed in the first frame (but displayed after).
  77168. * In consequence it is impossible to get material information in your HTML file
  77169. *
  77170. * @param url The URL of the MTL file
  77171. * @param rootUrl
  77172. * @param onSuccess Callback function to be called when the MTL file is loaded
  77173. * @private
  77174. */
  77175. private _loadMTL;
  77176. /**
  77177. * Instantiates a OBJ file loader plugin.
  77178. * @returns the created plugin
  77179. */
  77180. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77181. /**
  77182. * If the data string can be loaded directly.
  77183. *
  77184. * @param data string containing the file data
  77185. * @returns if the data can be loaded directly
  77186. */
  77187. canDirectLoad(data: string): boolean;
  77188. /**
  77189. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77190. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77191. * @param scene the scene the meshes should be added to
  77192. * @param data the OBJ data to load
  77193. * @param rootUrl root url to load from
  77194. * @param onProgress event that fires when loading progress has occured
  77195. * @param fileName Defines the name of the file to load
  77196. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77197. */
  77198. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77199. meshes: AbstractMesh[];
  77200. particleSystems: IParticleSystem[];
  77201. skeletons: Skeleton[];
  77202. animationGroups: AnimationGroup[];
  77203. }>;
  77204. /**
  77205. * Imports all objects from the loaded OBJ data and adds them to the scene
  77206. * @param scene the scene the objects should be added to
  77207. * @param data the OBJ data to load
  77208. * @param rootUrl root url to load from
  77209. * @param onProgress event that fires when loading progress has occured
  77210. * @param fileName Defines the name of the file to load
  77211. * @returns a promise which completes when objects have been loaded to the scene
  77212. */
  77213. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77214. /**
  77215. * Load into an asset container.
  77216. * @param scene The scene to load into
  77217. * @param data The data to import
  77218. * @param rootUrl The root url for scene and resources
  77219. * @param onProgress The callback when the load progresses
  77220. * @param fileName Defines the name of the file to load
  77221. * @returns The loaded asset container
  77222. */
  77223. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77224. /**
  77225. * Read the OBJ file and create an Array of meshes.
  77226. * Each mesh contains all information given by the OBJ and the MTL file.
  77227. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77228. *
  77229. * @param meshesNames
  77230. * @param scene Scene The scene where are displayed the data
  77231. * @param data String The content of the obj file
  77232. * @param rootUrl String The path to the folder
  77233. * @returns Array<AbstractMesh>
  77234. * @private
  77235. */
  77236. private _parseSolid;
  77237. }
  77238. }
  77239. declare module BABYLON {
  77240. /**
  77241. * STL file type loader.
  77242. * This is a babylon scene loader plugin.
  77243. */
  77244. export class STLFileLoader implements ISceneLoaderPlugin {
  77245. /** @hidden */
  77246. solidPattern: RegExp;
  77247. /** @hidden */
  77248. facetsPattern: RegExp;
  77249. /** @hidden */
  77250. normalPattern: RegExp;
  77251. /** @hidden */
  77252. vertexPattern: RegExp;
  77253. /**
  77254. * Defines the name of the plugin.
  77255. */
  77256. name: string;
  77257. /**
  77258. * Defines the extensions the stl loader is able to load.
  77259. * force data to come in as an ArrayBuffer
  77260. * we'll convert to string if it looks like it's an ASCII .stl
  77261. */
  77262. extensions: ISceneLoaderPluginExtensions;
  77263. /**
  77264. * Import meshes into a scene.
  77265. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77266. * @param scene The scene to import into
  77267. * @param data The data to import
  77268. * @param rootUrl The root url for scene and resources
  77269. * @param meshes The meshes array to import into
  77270. * @param particleSystems The particle systems array to import into
  77271. * @param skeletons The skeletons array to import into
  77272. * @param onError The callback when import fails
  77273. * @returns True if successful or false otherwise
  77274. */
  77275. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77276. /**
  77277. * Load into a scene.
  77278. * @param scene The scene to load into
  77279. * @param data The data to import
  77280. * @param rootUrl The root url for scene and resources
  77281. * @param onError The callback when import fails
  77282. * @returns true if successful or false otherwise
  77283. */
  77284. load(scene: Scene, data: any, rootUrl: string): boolean;
  77285. /**
  77286. * Load into an asset container.
  77287. * @param scene The scene to load into
  77288. * @param data The data to import
  77289. * @param rootUrl The root url for scene and resources
  77290. * @param onError The callback when import fails
  77291. * @returns The loaded asset container
  77292. */
  77293. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77294. private _isBinary;
  77295. private _parseBinary;
  77296. private _parseASCII;
  77297. }
  77298. }
  77299. declare module BABYLON {
  77300. /**
  77301. * Class for generating OBJ data from a Babylon scene.
  77302. */
  77303. export class OBJExport {
  77304. /**
  77305. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77306. * @param mesh defines the list of meshes to serialize
  77307. * @param materials defines if materials should be exported
  77308. * @param matlibname defines the name of the associated mtl file
  77309. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77310. * @returns the OBJ content
  77311. */
  77312. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77313. /**
  77314. * Exports the material(s) of a mesh in .MTL file format (text)
  77315. * @param mesh defines the mesh to extract the material from
  77316. * @returns the mtl content
  77317. */
  77318. static MTL(mesh: Mesh): string;
  77319. }
  77320. }
  77321. declare module BABYLON {
  77322. /** @hidden */
  77323. export var __IGLTFExporterExtension: number;
  77324. /**
  77325. * Interface for extending the exporter
  77326. * @hidden
  77327. */
  77328. export interface IGLTFExporterExtension {
  77329. /**
  77330. * The name of this extension
  77331. */
  77332. readonly name: string;
  77333. /**
  77334. * Defines whether this extension is enabled
  77335. */
  77336. enabled: boolean;
  77337. /**
  77338. * Defines whether this extension is required
  77339. */
  77340. required: boolean;
  77341. }
  77342. }
  77343. declare module BABYLON.GLTF2.Exporter {
  77344. /** @hidden */
  77345. export var __IGLTFExporterExtensionV2: number;
  77346. /**
  77347. * Interface for a glTF exporter extension
  77348. * @hidden
  77349. */
  77350. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77351. /**
  77352. * Define this method to modify the default behavior before exporting a texture
  77353. * @param context The context when loading the asset
  77354. * @param babylonTexture The Babylon.js texture
  77355. * @param mimeType The mime-type of the generated image
  77356. * @returns A promise that resolves with the exported texture
  77357. */
  77358. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77359. /**
  77360. * Define this method to get notified when a texture info is created
  77361. * @param context The context when loading the asset
  77362. * @param textureInfo The glTF texture info
  77363. * @param babylonTexture The Babylon.js texture
  77364. */
  77365. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77366. /**
  77367. * Define this method to modify the default behavior when exporting texture info
  77368. * @param context The context when loading the asset
  77369. * @param meshPrimitive glTF mesh primitive
  77370. * @param babylonSubMesh Babylon submesh
  77371. * @param binaryWriter glTF serializer binary writer instance
  77372. * @returns nullable IMeshPrimitive promise
  77373. */
  77374. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77375. /**
  77376. * Define this method to modify the default behavior when exporting a node
  77377. * @param context The context when exporting the node
  77378. * @param node glTF node
  77379. * @param babylonNode BabylonJS node
  77380. * @returns nullable INode promise
  77381. */
  77382. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77383. [key: number]: number;
  77384. }): Promise<Nullable<INode>>;
  77385. /**
  77386. * Define this method to modify the default behavior when exporting a material
  77387. * @param material glTF material
  77388. * @param babylonMaterial BabylonJS material
  77389. * @returns nullable IMaterial promise
  77390. */
  77391. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77392. /**
  77393. * Define this method to return additional textures to export from a material
  77394. * @param material glTF material
  77395. * @param babylonMaterial BabylonJS material
  77396. * @returns List of textures
  77397. */
  77398. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77399. /** Gets a boolean indicating that this extension was used */
  77400. wasUsed: boolean;
  77401. /** Gets a boolean indicating that this extension is required for the file to work */
  77402. required: boolean;
  77403. /**
  77404. * Called after the exporter state changes to EXPORTING
  77405. */
  77406. onExporting?(): void;
  77407. }
  77408. }
  77409. declare module BABYLON.GLTF2.Exporter {
  77410. /**
  77411. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77412. * @hidden
  77413. */
  77414. export class _GLTFMaterialExporter {
  77415. /**
  77416. * Represents the dielectric specular values for R, G and B
  77417. */
  77418. private static readonly _DielectricSpecular;
  77419. /**
  77420. * Allows the maximum specular power to be defined for material calculations
  77421. */
  77422. private static readonly _MaxSpecularPower;
  77423. /**
  77424. * Mapping to store textures
  77425. */
  77426. private _textureMap;
  77427. /**
  77428. * Numeric tolerance value
  77429. */
  77430. private static readonly _Epsilon;
  77431. /**
  77432. * Reference to the glTF Exporter
  77433. */
  77434. private _exporter;
  77435. constructor(exporter: _Exporter);
  77436. /**
  77437. * Specifies if two colors are approximately equal in value
  77438. * @param color1 first color to compare to
  77439. * @param color2 second color to compare to
  77440. * @param epsilon threshold value
  77441. */
  77442. private static FuzzyEquals;
  77443. /**
  77444. * Gets the materials from a Babylon scene and converts them to glTF materials
  77445. * @param scene babylonjs scene
  77446. * @param mimeType texture mime type
  77447. * @param images array of images
  77448. * @param textures array of textures
  77449. * @param materials array of materials
  77450. * @param imageData mapping of texture names to base64 textures
  77451. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77452. */
  77453. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77454. /**
  77455. * Makes a copy of the glTF material without the texture parameters
  77456. * @param originalMaterial original glTF material
  77457. * @returns glTF material without texture parameters
  77458. */
  77459. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77460. /**
  77461. * Specifies if the material has any texture parameters present
  77462. * @param material glTF Material
  77463. * @returns boolean specifying if texture parameters are present
  77464. */
  77465. _hasTexturesPresent(material: IMaterial): boolean;
  77466. /**
  77467. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77468. * @param babylonStandardMaterial
  77469. * @returns glTF Metallic Roughness Material representation
  77470. */
  77471. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77472. /**
  77473. * Computes the metallic factor
  77474. * @param diffuse diffused value
  77475. * @param specular specular value
  77476. * @param oneMinusSpecularStrength one minus the specular strength
  77477. * @returns metallic value
  77478. */
  77479. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77480. /**
  77481. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77482. * @param glTFMaterial glTF material
  77483. * @param babylonMaterial Babylon material
  77484. */
  77485. private static _SetAlphaMode;
  77486. /**
  77487. * Converts a Babylon Standard Material to a glTF Material
  77488. * @param babylonStandardMaterial BJS Standard Material
  77489. * @param mimeType mime type to use for the textures
  77490. * @param images array of glTF image interfaces
  77491. * @param textures array of glTF texture interfaces
  77492. * @param materials array of glTF material interfaces
  77493. * @param imageData map of image file name to data
  77494. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77495. */
  77496. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77497. private _finishMaterial;
  77498. /**
  77499. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77500. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77501. * @param mimeType mime type to use for the textures
  77502. * @param images array of glTF image interfaces
  77503. * @param textures array of glTF texture interfaces
  77504. * @param materials array of glTF material interfaces
  77505. * @param imageData map of image file name to data
  77506. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77507. */
  77508. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77509. /**
  77510. * Converts an image typed array buffer to a base64 image
  77511. * @param buffer typed array buffer
  77512. * @param width width of the image
  77513. * @param height height of the image
  77514. * @param mimeType mimetype of the image
  77515. * @returns base64 image string
  77516. */
  77517. private _createBase64FromCanvasAsync;
  77518. /**
  77519. * Generates a white texture based on the specified width and height
  77520. * @param width width of the texture in pixels
  77521. * @param height height of the texture in pixels
  77522. * @param scene babylonjs scene
  77523. * @returns white texture
  77524. */
  77525. private _createWhiteTexture;
  77526. /**
  77527. * 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
  77528. * @param texture1 first texture to resize
  77529. * @param texture2 second texture to resize
  77530. * @param scene babylonjs scene
  77531. * @returns resized textures or null
  77532. */
  77533. private _resizeTexturesToSameDimensions;
  77534. /**
  77535. * Converts an array of pixels to a Float32Array
  77536. * Throws an error if the pixel format is not supported
  77537. * @param pixels - array buffer containing pixel values
  77538. * @returns Float32 of pixels
  77539. */
  77540. private _convertPixelArrayToFloat32;
  77541. /**
  77542. * Convert Specular Glossiness Textures to Metallic Roughness
  77543. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77544. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77545. * @param diffuseTexture texture used to store diffuse information
  77546. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77547. * @param factors specular glossiness material factors
  77548. * @param mimeType the mime type to use for the texture
  77549. * @returns pbr metallic roughness interface or null
  77550. */
  77551. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77552. /**
  77553. * Converts specular glossiness material properties to metallic roughness
  77554. * @param specularGlossiness interface with specular glossiness material properties
  77555. * @returns interface with metallic roughness material properties
  77556. */
  77557. private _convertSpecularGlossinessToMetallicRoughness;
  77558. /**
  77559. * Calculates the surface reflectance, independent of lighting conditions
  77560. * @param color Color source to calculate brightness from
  77561. * @returns number representing the perceived brightness, or zero if color is undefined
  77562. */
  77563. private _getPerceivedBrightness;
  77564. /**
  77565. * Returns the maximum color component value
  77566. * @param color
  77567. * @returns maximum color component value, or zero if color is null or undefined
  77568. */
  77569. private _getMaxComponent;
  77570. /**
  77571. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77572. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77573. * @param mimeType mime type to use for the textures
  77574. * @param images array of glTF image interfaces
  77575. * @param textures array of glTF texture interfaces
  77576. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77577. * @param imageData map of image file name to data
  77578. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77579. * @returns glTF PBR Metallic Roughness factors
  77580. */
  77581. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77582. private _getGLTFTextureSampler;
  77583. private _getGLTFTextureWrapMode;
  77584. private _getGLTFTextureWrapModesSampler;
  77585. /**
  77586. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77587. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77588. * @param mimeType mime type to use for the textures
  77589. * @param images array of glTF image interfaces
  77590. * @param textures array of glTF texture interfaces
  77591. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77592. * @param imageData map of image file name to data
  77593. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77594. * @returns glTF PBR Metallic Roughness factors
  77595. */
  77596. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77597. /**
  77598. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77599. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77600. * @param mimeType mime type to use for the textures
  77601. * @param images array of glTF image interfaces
  77602. * @param textures array of glTF texture interfaces
  77603. * @param materials array of glTF material interfaces
  77604. * @param imageData map of image file name to data
  77605. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77606. */
  77607. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77608. private setMetallicRoughnessPbrMaterial;
  77609. private getPixelsFromTexture;
  77610. /**
  77611. * Extracts a texture from a Babylon texture into file data and glTF data
  77612. * @param babylonTexture Babylon texture to extract
  77613. * @param mimeType Mime Type of the babylonTexture
  77614. * @return glTF texture info, or null if the texture format is not supported
  77615. */
  77616. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77617. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77618. /**
  77619. * Builds a texture from base64 string
  77620. * @param base64Texture base64 texture string
  77621. * @param baseTextureName Name to use for the texture
  77622. * @param mimeType image mime type for the texture
  77623. * @param images array of images
  77624. * @param textures array of textures
  77625. * @param imageData map of image data
  77626. * @returns glTF texture info, or null if the texture format is not supported
  77627. */
  77628. private _getTextureInfoFromBase64;
  77629. }
  77630. }
  77631. declare module BABYLON {
  77632. /**
  77633. * Class for holding and downloading glTF file data
  77634. */
  77635. export class GLTFData {
  77636. /**
  77637. * Object which contains the file name as the key and its data as the value
  77638. */
  77639. glTFFiles: {
  77640. [fileName: string]: string | Blob;
  77641. };
  77642. /**
  77643. * Initializes the glTF file object
  77644. */
  77645. constructor();
  77646. /**
  77647. * Downloads the glTF data as files based on their names and data
  77648. */
  77649. downloadFiles(): void;
  77650. }
  77651. }
  77652. declare module BABYLON {
  77653. /**
  77654. * Holds a collection of exporter options and parameters
  77655. */
  77656. export interface IExportOptions {
  77657. /**
  77658. * Function which indicates whether a babylon node should be exported or not
  77659. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77660. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77661. */
  77662. shouldExportNode?(node: Node): boolean;
  77663. /**
  77664. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77665. * @param metadata source metadata to read from
  77666. * @returns the data to store to glTF node extras
  77667. */
  77668. metadataSelector?(metadata: any): any;
  77669. /**
  77670. * The sample rate to bake animation curves
  77671. */
  77672. animationSampleRate?: number;
  77673. /**
  77674. * Begin serialization without waiting for the scene to be ready
  77675. */
  77676. exportWithoutWaitingForScene?: boolean;
  77677. /**
  77678. * Indicates if coordinate system swapping root nodes should be included in export
  77679. */
  77680. includeCoordinateSystemConversionNodes?: boolean;
  77681. }
  77682. /**
  77683. * Class for generating glTF data from a Babylon scene.
  77684. */
  77685. export class GLTF2Export {
  77686. /**
  77687. * Exports the geometry of the scene to .gltf file format asynchronously
  77688. * @param scene Babylon scene with scene hierarchy information
  77689. * @param filePrefix File prefix to use when generating the glTF file
  77690. * @param options Exporter options
  77691. * @returns Returns an object with a .gltf file and associates texture names
  77692. * as keys and their data and paths as values
  77693. */
  77694. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77695. private static _PreExportAsync;
  77696. private static _PostExportAsync;
  77697. /**
  77698. * Exports the geometry of the scene to .glb file format asychronously
  77699. * @param scene Babylon scene with scene hierarchy information
  77700. * @param filePrefix File prefix to use when generating glb file
  77701. * @param options Exporter options
  77702. * @returns Returns an object with a .glb filename as key and data as value
  77703. */
  77704. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77705. }
  77706. }
  77707. declare module BABYLON.GLTF2.Exporter {
  77708. /**
  77709. * @hidden
  77710. */
  77711. export class _GLTFUtilities {
  77712. /**
  77713. * Creates a buffer view based on the supplied arguments
  77714. * @param bufferIndex index value of the specified buffer
  77715. * @param byteOffset byte offset value
  77716. * @param byteLength byte length of the bufferView
  77717. * @param byteStride byte distance between conequential elements
  77718. * @param name name of the buffer view
  77719. * @returns bufferView for glTF
  77720. */
  77721. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77722. /**
  77723. * Creates an accessor based on the supplied arguments
  77724. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77725. * @param name The name of the accessor
  77726. * @param type The type of the accessor
  77727. * @param componentType The datatype of components in the attribute
  77728. * @param count The number of attributes referenced by this accessor
  77729. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77730. * @param min Minimum value of each component in this attribute
  77731. * @param max Maximum value of each component in this attribute
  77732. * @returns accessor for glTF
  77733. */
  77734. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77735. /**
  77736. * Calculates the minimum and maximum values of an array of position floats
  77737. * @param positions Positions array of a mesh
  77738. * @param vertexStart Starting vertex offset to calculate min and max values
  77739. * @param vertexCount Number of vertices to check for min and max values
  77740. * @returns min number array and max number array
  77741. */
  77742. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77743. min: number[];
  77744. max: number[];
  77745. };
  77746. /**
  77747. * Converts a new right-handed Vector3
  77748. * @param vector vector3 array
  77749. * @returns right-handed Vector3
  77750. */
  77751. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77752. /**
  77753. * Converts a Vector3 to right-handed
  77754. * @param vector Vector3 to convert to right-handed
  77755. */
  77756. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77757. /**
  77758. * Converts a three element number array to right-handed
  77759. * @param vector number array to convert to right-handed
  77760. */
  77761. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77762. /**
  77763. * Converts a new right-handed Vector3
  77764. * @param vector vector3 array
  77765. * @returns right-handed Vector3
  77766. */
  77767. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77768. /**
  77769. * Converts a Vector3 to right-handed
  77770. * @param vector Vector3 to convert to right-handed
  77771. */
  77772. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77773. /**
  77774. * Converts a three element number array to right-handed
  77775. * @param vector number array to convert to right-handed
  77776. */
  77777. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77778. /**
  77779. * Converts a Vector4 to right-handed
  77780. * @param vector Vector4 to convert to right-handed
  77781. */
  77782. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77783. /**
  77784. * Converts a Vector4 to right-handed
  77785. * @param vector Vector4 to convert to right-handed
  77786. */
  77787. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77788. /**
  77789. * Converts a Quaternion to right-handed
  77790. * @param quaternion Source quaternion to convert to right-handed
  77791. */
  77792. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77793. /**
  77794. * Converts a Quaternion to right-handed
  77795. * @param quaternion Source quaternion to convert to right-handed
  77796. */
  77797. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77798. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77799. }
  77800. }
  77801. declare module BABYLON.GLTF2.Exporter {
  77802. /**
  77803. * Converts Babylon Scene into glTF 2.0.
  77804. * @hidden
  77805. */
  77806. export class _Exporter {
  77807. /**
  77808. * Stores the glTF to export
  77809. */
  77810. _glTF: IGLTF;
  77811. /**
  77812. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77813. */
  77814. _bufferViews: IBufferView[];
  77815. /**
  77816. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77817. */
  77818. _accessors: IAccessor[];
  77819. /**
  77820. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77821. */
  77822. _nodes: INode[];
  77823. /**
  77824. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77825. */
  77826. private _scenes;
  77827. /**
  77828. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77829. */
  77830. private _meshes;
  77831. /**
  77832. * Stores all the generated material information, which represents the appearance of each primitive
  77833. */
  77834. _materials: IMaterial[];
  77835. _materialMap: {
  77836. [materialID: number]: number;
  77837. };
  77838. /**
  77839. * Stores all the generated texture information, which is referenced by glTF materials
  77840. */
  77841. _textures: ITexture[];
  77842. /**
  77843. * Stores all the generated image information, which is referenced by glTF textures
  77844. */
  77845. _images: IImage[];
  77846. /**
  77847. * Stores all the texture samplers
  77848. */
  77849. _samplers: ISampler[];
  77850. /**
  77851. * Stores all the generated animation samplers, which is referenced by glTF animations
  77852. */
  77853. /**
  77854. * Stores the animations for glTF models
  77855. */
  77856. private _animations;
  77857. /**
  77858. * Stores the total amount of bytes stored in the glTF buffer
  77859. */
  77860. private _totalByteLength;
  77861. /**
  77862. * Stores a reference to the Babylon scene containing the source geometry and material information
  77863. */
  77864. _babylonScene: Scene;
  77865. /**
  77866. * Stores a map of the image data, where the key is the file name and the value
  77867. * is the image data
  77868. */
  77869. _imageData: {
  77870. [fileName: string]: {
  77871. data: Uint8Array;
  77872. mimeType: ImageMimeType;
  77873. };
  77874. };
  77875. /**
  77876. * Stores a map of the unique id of a node to its index in the node array
  77877. */
  77878. _nodeMap: {
  77879. [key: number]: number;
  77880. };
  77881. /**
  77882. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77883. */
  77884. _convertToRightHandedSystem: boolean;
  77885. /**
  77886. * Specifies if a Babylon node should be converted to right-handed on export
  77887. */
  77888. _convertToRightHandedSystemMap: {
  77889. [nodeId: number]: boolean;
  77890. };
  77891. _includeCoordinateSystemConversionNodes: boolean;
  77892. /**
  77893. * Baked animation sample rate
  77894. */
  77895. private _animationSampleRate;
  77896. private _options;
  77897. private _localEngine;
  77898. _glTFMaterialExporter: _GLTFMaterialExporter;
  77899. private _extensions;
  77900. private static _ExtensionNames;
  77901. private static _ExtensionFactories;
  77902. private _applyExtension;
  77903. private _applyExtensions;
  77904. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77905. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77906. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77907. [key: number]: number;
  77908. }): Promise<Nullable<INode>>;
  77909. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77910. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77911. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77912. private _forEachExtensions;
  77913. private _extensionsOnExporting;
  77914. /**
  77915. * Load glTF serializer extensions
  77916. */
  77917. private _loadExtensions;
  77918. /**
  77919. * Creates a glTF Exporter instance, which can accept optional exporter options
  77920. * @param babylonScene Babylon scene object
  77921. * @param options Options to modify the behavior of the exporter
  77922. */
  77923. constructor(babylonScene: Scene, options?: IExportOptions);
  77924. dispose(): void;
  77925. /**
  77926. * Registers a glTF exporter extension
  77927. * @param name Name of the extension to export
  77928. * @param factory The factory function that creates the exporter extension
  77929. */
  77930. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77931. /**
  77932. * Un-registers an exporter extension
  77933. * @param name The name fo the exporter extension
  77934. * @returns A boolean indicating whether the extension has been un-registered
  77935. */
  77936. static UnregisterExtension(name: string): boolean;
  77937. /**
  77938. * Lazy load a local engine
  77939. */
  77940. _getLocalEngine(): Engine;
  77941. private reorderIndicesBasedOnPrimitiveMode;
  77942. /**
  77943. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77944. * clock-wise during export to glTF
  77945. * @param submesh BabylonJS submesh
  77946. * @param primitiveMode Primitive mode of the mesh
  77947. * @param sideOrientation the winding order of the submesh
  77948. * @param vertexBufferKind The type of vertex attribute
  77949. * @param meshAttributeArray The vertex attribute data
  77950. * @param byteOffset The offset to the binary data
  77951. * @param binaryWriter The binary data for the glTF file
  77952. * @param convertToRightHandedSystem Converts the values to right-handed
  77953. */
  77954. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77955. /**
  77956. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77957. * clock-wise during export to glTF
  77958. * @param submesh BabylonJS submesh
  77959. * @param primitiveMode Primitive mode of the mesh
  77960. * @param sideOrientation the winding order of the submesh
  77961. * @param vertexBufferKind The type of vertex attribute
  77962. * @param meshAttributeArray The vertex attribute data
  77963. * @param byteOffset The offset to the binary data
  77964. * @param binaryWriter The binary data for the glTF file
  77965. * @param convertToRightHandedSystem Converts the values to right-handed
  77966. */
  77967. private reorderTriangleFillMode;
  77968. /**
  77969. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77970. * clock-wise during export to glTF
  77971. * @param submesh BabylonJS submesh
  77972. * @param primitiveMode Primitive mode of the mesh
  77973. * @param sideOrientation the winding order of the submesh
  77974. * @param vertexBufferKind The type of vertex attribute
  77975. * @param meshAttributeArray The vertex attribute data
  77976. * @param byteOffset The offset to the binary data
  77977. * @param binaryWriter The binary data for the glTF file
  77978. * @param convertToRightHandedSystem Converts the values to right-handed
  77979. */
  77980. private reorderTriangleStripDrawMode;
  77981. /**
  77982. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77983. * clock-wise during export to glTF
  77984. * @param submesh BabylonJS submesh
  77985. * @param primitiveMode Primitive mode of the mesh
  77986. * @param sideOrientation the winding order of the submesh
  77987. * @param vertexBufferKind The type of vertex attribute
  77988. * @param meshAttributeArray The vertex attribute data
  77989. * @param byteOffset The offset to the binary data
  77990. * @param binaryWriter The binary data for the glTF file
  77991. * @param convertToRightHandedSystem Converts the values to right-handed
  77992. */
  77993. private reorderTriangleFanMode;
  77994. /**
  77995. * Writes the vertex attribute data to binary
  77996. * @param vertices The vertices to write to the binary writer
  77997. * @param byteOffset The offset into the binary writer to overwrite binary data
  77998. * @param vertexAttributeKind The vertex attribute type
  77999. * @param meshAttributeArray The vertex attribute data
  78000. * @param binaryWriter The writer containing the binary data
  78001. * @param convertToRightHandedSystem Converts the values to right-handed
  78002. */
  78003. private writeVertexAttributeData;
  78004. /**
  78005. * Writes mesh attribute data to a data buffer
  78006. * Returns the bytelength of the data
  78007. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78008. * @param meshAttributeArray Array containing the attribute data
  78009. * @param binaryWriter The buffer to write the binary data to
  78010. * @param indices Used to specify the order of the vertex data
  78011. * @param convertToRightHandedSystem Converts the values to right-handed
  78012. */
  78013. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78014. /**
  78015. * Generates glTF json data
  78016. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78017. * @param glTFPrefix Text to use when prefixing a glTF file
  78018. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78019. * @returns json data as string
  78020. */
  78021. private generateJSON;
  78022. /**
  78023. * Generates data for .gltf and .bin files based on the glTF prefix string
  78024. * @param glTFPrefix Text to use when prefixing a glTF file
  78025. * @param dispose Dispose the exporter
  78026. * @returns GLTFData with glTF file data
  78027. */
  78028. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78029. /**
  78030. * Creates a binary buffer for glTF
  78031. * @returns array buffer for binary data
  78032. */
  78033. private _generateBinaryAsync;
  78034. /**
  78035. * Pads the number to a multiple of 4
  78036. * @param num number to pad
  78037. * @returns padded number
  78038. */
  78039. private _getPadding;
  78040. /**
  78041. * @hidden
  78042. */
  78043. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78044. /**
  78045. * Sets the TRS for each node
  78046. * @param node glTF Node for storing the transformation data
  78047. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78048. * @param convertToRightHandedSystem Converts the values to right-handed
  78049. */
  78050. private setNodeTransformation;
  78051. private getVertexBufferFromMesh;
  78052. /**
  78053. * Creates a bufferview based on the vertices type for the Babylon mesh
  78054. * @param kind Indicates the type of vertices data
  78055. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78056. * @param binaryWriter The buffer to write the bufferview data to
  78057. * @param convertToRightHandedSystem Converts the values to right-handed
  78058. */
  78059. private createBufferViewKind;
  78060. /**
  78061. * The primitive mode of the Babylon mesh
  78062. * @param babylonMesh The BabylonJS mesh
  78063. */
  78064. private getMeshPrimitiveMode;
  78065. /**
  78066. * Sets the primitive mode of the glTF mesh primitive
  78067. * @param meshPrimitive glTF mesh primitive
  78068. * @param primitiveMode The primitive mode
  78069. */
  78070. private setPrimitiveMode;
  78071. /**
  78072. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78073. * @param meshPrimitive glTF mesh primitive
  78074. * @param attributeKind vertex attribute
  78075. * @returns boolean specifying if uv coordinates are present
  78076. */
  78077. private setAttributeKind;
  78078. /**
  78079. * Sets data for the primitive attributes of each submesh
  78080. * @param mesh glTF Mesh object to store the primitive attribute information
  78081. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78082. * @param binaryWriter Buffer to write the attribute data to
  78083. * @param convertToRightHandedSystem Converts the values to right-handed
  78084. */
  78085. private setPrimitiveAttributesAsync;
  78086. /**
  78087. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78088. * @param node The node to check
  78089. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78090. */
  78091. private isBabylonCoordinateSystemConvertingNode;
  78092. /**
  78093. * Creates a glTF scene based on the array of meshes
  78094. * Returns the the total byte offset
  78095. * @param babylonScene Babylon scene to get the mesh data from
  78096. * @param binaryWriter Buffer to write binary data to
  78097. */
  78098. private createSceneAsync;
  78099. /**
  78100. * Creates a mapping of Node unique id to node index and handles animations
  78101. * @param babylonScene Babylon Scene
  78102. * @param nodes Babylon transform nodes
  78103. * @param binaryWriter Buffer to write binary data to
  78104. * @returns Node mapping of unique id to index
  78105. */
  78106. private createNodeMapAndAnimationsAsync;
  78107. /**
  78108. * Creates a glTF node from a Babylon mesh
  78109. * @param babylonMesh Source Babylon mesh
  78110. * @param binaryWriter Buffer for storing geometry data
  78111. * @param convertToRightHandedSystem Converts the values to right-handed
  78112. * @param nodeMap Node mapping of unique id to glTF node index
  78113. * @returns glTF node
  78114. */
  78115. private createNodeAsync;
  78116. }
  78117. /**
  78118. * @hidden
  78119. *
  78120. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78121. */
  78122. export class _BinaryWriter {
  78123. /**
  78124. * Array buffer which stores all binary data
  78125. */
  78126. private _arrayBuffer;
  78127. /**
  78128. * View of the array buffer
  78129. */
  78130. private _dataView;
  78131. /**
  78132. * byte offset of data in array buffer
  78133. */
  78134. private _byteOffset;
  78135. /**
  78136. * Initialize binary writer with an initial byte length
  78137. * @param byteLength Initial byte length of the array buffer
  78138. */
  78139. constructor(byteLength: number);
  78140. /**
  78141. * Resize the array buffer to the specified byte length
  78142. * @param byteLength
  78143. */
  78144. private resizeBuffer;
  78145. /**
  78146. * Get an array buffer with the length of the byte offset
  78147. * @returns ArrayBuffer resized to the byte offset
  78148. */
  78149. getArrayBuffer(): ArrayBuffer;
  78150. /**
  78151. * Get the byte offset of the array buffer
  78152. * @returns byte offset
  78153. */
  78154. getByteOffset(): number;
  78155. /**
  78156. * Stores an UInt8 in the array buffer
  78157. * @param entry
  78158. * @param byteOffset If defined, specifies where to set the value as an offset.
  78159. */
  78160. setUInt8(entry: number, byteOffset?: number): void;
  78161. /**
  78162. * Gets an UInt32 in the array buffer
  78163. * @param entry
  78164. * @param byteOffset If defined, specifies where to set the value as an offset.
  78165. */
  78166. getUInt32(byteOffset: number): number;
  78167. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78168. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78169. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78170. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78171. /**
  78172. * Stores a Float32 in the array buffer
  78173. * @param entry
  78174. */
  78175. setFloat32(entry: number, byteOffset?: number): void;
  78176. /**
  78177. * Stores an UInt32 in the array buffer
  78178. * @param entry
  78179. * @param byteOffset If defined, specifies where to set the value as an offset.
  78180. */
  78181. setUInt32(entry: number, byteOffset?: number): void;
  78182. }
  78183. }
  78184. declare module BABYLON.GLTF2.Exporter {
  78185. /**
  78186. * @hidden
  78187. * Interface to store animation data.
  78188. */
  78189. export interface _IAnimationData {
  78190. /**
  78191. * Keyframe data.
  78192. */
  78193. inputs: number[];
  78194. /**
  78195. * Value data.
  78196. */
  78197. outputs: number[][];
  78198. /**
  78199. * Animation interpolation data.
  78200. */
  78201. samplerInterpolation: AnimationSamplerInterpolation;
  78202. /**
  78203. * Minimum keyframe value.
  78204. */
  78205. inputsMin: number;
  78206. /**
  78207. * Maximum keyframe value.
  78208. */
  78209. inputsMax: number;
  78210. }
  78211. /**
  78212. * @hidden
  78213. */
  78214. export interface _IAnimationInfo {
  78215. /**
  78216. * The target channel for the animation
  78217. */
  78218. animationChannelTargetPath: AnimationChannelTargetPath;
  78219. /**
  78220. * The glTF accessor type for the data.
  78221. */
  78222. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78223. /**
  78224. * Specifies if quaternions should be used.
  78225. */
  78226. useQuaternion: boolean;
  78227. }
  78228. /**
  78229. * @hidden
  78230. * Utility class for generating glTF animation data from BabylonJS.
  78231. */
  78232. export class _GLTFAnimation {
  78233. /**
  78234. * @ignore
  78235. *
  78236. * Creates glTF channel animation from BabylonJS animation.
  78237. * @param babylonTransformNode - BabylonJS mesh.
  78238. * @param animation - animation.
  78239. * @param animationChannelTargetPath - The target animation channel.
  78240. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78241. * @param useQuaternion - Specifies if quaternions are used.
  78242. * @returns nullable IAnimationData
  78243. */
  78244. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78245. private static _DeduceAnimationInfo;
  78246. /**
  78247. * @ignore
  78248. * Create node animations from the transform node animations
  78249. * @param babylonNode
  78250. * @param runtimeGLTFAnimation
  78251. * @param idleGLTFAnimations
  78252. * @param nodeMap
  78253. * @param nodes
  78254. * @param binaryWriter
  78255. * @param bufferViews
  78256. * @param accessors
  78257. * @param convertToRightHandedSystem
  78258. * @param animationSampleRate
  78259. */
  78260. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78261. [key: number]: number;
  78262. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78263. /**
  78264. * @ignore
  78265. * Create node animations from the animation groups
  78266. * @param babylonScene
  78267. * @param glTFAnimations
  78268. * @param nodeMap
  78269. * @param nodes
  78270. * @param binaryWriter
  78271. * @param bufferViews
  78272. * @param accessors
  78273. * @param convertToRightHandedSystemMap
  78274. * @param animationSampleRate
  78275. */
  78276. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78277. [key: number]: number;
  78278. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78279. [nodeId: number]: boolean;
  78280. }, animationSampleRate: number): void;
  78281. private static AddAnimation;
  78282. /**
  78283. * Create a baked animation
  78284. * @param babylonTransformNode BabylonJS mesh
  78285. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78286. * @param animationChannelTargetPath animation target channel
  78287. * @param minFrame minimum animation frame
  78288. * @param maxFrame maximum animation frame
  78289. * @param fps frames per second of the animation
  78290. * @param inputs input key frames of the animation
  78291. * @param outputs output key frame data of the animation
  78292. * @param convertToRightHandedSystem converts the values to right-handed
  78293. * @param useQuaternion specifies if quaternions should be used
  78294. */
  78295. private static _CreateBakedAnimation;
  78296. private static _ConvertFactorToVector3OrQuaternion;
  78297. private static _SetInterpolatedValue;
  78298. /**
  78299. * Creates linear animation from the animation key frames
  78300. * @param babylonTransformNode BabylonJS mesh
  78301. * @param animation BabylonJS animation
  78302. * @param animationChannelTargetPath The target animation channel
  78303. * @param frameDelta The difference between the last and first frame of the animation
  78304. * @param inputs Array to store the key frame times
  78305. * @param outputs Array to store the key frame data
  78306. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78307. * @param useQuaternion Specifies if quaternions are used in the animation
  78308. */
  78309. private static _CreateLinearOrStepAnimation;
  78310. /**
  78311. * Creates cubic spline animation from the animation key frames
  78312. * @param babylonTransformNode BabylonJS mesh
  78313. * @param animation BabylonJS animation
  78314. * @param animationChannelTargetPath The target animation channel
  78315. * @param frameDelta The difference between the last and first frame of the animation
  78316. * @param inputs Array to store the key frame times
  78317. * @param outputs Array to store the key frame data
  78318. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78319. * @param useQuaternion Specifies if quaternions are used in the animation
  78320. */
  78321. private static _CreateCubicSplineAnimation;
  78322. private static _GetBasePositionRotationOrScale;
  78323. /**
  78324. * Adds a key frame value
  78325. * @param keyFrame
  78326. * @param animation
  78327. * @param outputs
  78328. * @param animationChannelTargetPath
  78329. * @param basePositionRotationOrScale
  78330. * @param convertToRightHandedSystem
  78331. * @param useQuaternion
  78332. */
  78333. private static _AddKeyframeValue;
  78334. /**
  78335. * Determine the interpolation based on the key frames
  78336. * @param keyFrames
  78337. * @param animationChannelTargetPath
  78338. * @param useQuaternion
  78339. */
  78340. private static _DeduceInterpolation;
  78341. /**
  78342. * Adds an input tangent or output tangent to the output data
  78343. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78344. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78345. * @param outputs The animation data by keyframe
  78346. * @param animationChannelTargetPath The target animation channel
  78347. * @param interpolation The interpolation type
  78348. * @param keyFrame The key frame with the animation data
  78349. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78350. * @param useQuaternion Specifies if quaternions are used
  78351. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78352. */
  78353. private static AddSplineTangent;
  78354. /**
  78355. * Get the minimum and maximum key frames' frame values
  78356. * @param keyFrames animation key frames
  78357. * @returns the minimum and maximum key frame value
  78358. */
  78359. private static calculateMinMaxKeyFrames;
  78360. }
  78361. }
  78362. declare module BABYLON.GLTF2.Exporter {
  78363. /** @hidden */
  78364. export var textureTransformPixelShader: {
  78365. name: string;
  78366. shader: string;
  78367. };
  78368. }
  78369. declare module BABYLON.GLTF2.Exporter.Extensions {
  78370. /**
  78371. * @hidden
  78372. */
  78373. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78374. private _recordedTextures;
  78375. /** Name of this extension */
  78376. readonly name: string;
  78377. /** Defines whether this extension is enabled */
  78378. enabled: boolean;
  78379. /** Defines whether this extension is required */
  78380. required: boolean;
  78381. /** Reference to the glTF exporter */
  78382. private _wasUsed;
  78383. constructor(exporter: _Exporter);
  78384. dispose(): void;
  78385. /** @hidden */
  78386. get wasUsed(): boolean;
  78387. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78388. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78389. /**
  78390. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78391. * @param babylonTexture
  78392. * @param offset
  78393. * @param rotation
  78394. * @param scale
  78395. * @param scene
  78396. */
  78397. private _textureTransformTextureAsync;
  78398. }
  78399. }
  78400. declare module BABYLON.GLTF2.Exporter.Extensions {
  78401. /**
  78402. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78403. */
  78404. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78405. /** The name of this extension. */
  78406. readonly name: string;
  78407. /** Defines whether this extension is enabled. */
  78408. enabled: boolean;
  78409. /** Defines whether this extension is required */
  78410. required: boolean;
  78411. /** Reference to the glTF exporter */
  78412. private _exporter;
  78413. private _lights;
  78414. /** @hidden */
  78415. constructor(exporter: _Exporter);
  78416. /** @hidden */
  78417. dispose(): void;
  78418. /** @hidden */
  78419. get wasUsed(): boolean;
  78420. /** @hidden */
  78421. onExporting(): void;
  78422. /**
  78423. * Define this method to modify the default behavior when exporting a node
  78424. * @param context The context when exporting the node
  78425. * @param node glTF node
  78426. * @param babylonNode BabylonJS node
  78427. * @param nodeMap Node mapping of unique id to glTF node index
  78428. * @returns nullable INode promise
  78429. */
  78430. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78431. [key: number]: number;
  78432. }): Promise<Nullable<INode>>;
  78433. }
  78434. }
  78435. declare module BABYLON.GLTF2.Exporter.Extensions {
  78436. /**
  78437. * @hidden
  78438. */
  78439. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78440. /** Name of this extension */
  78441. readonly name: string;
  78442. /** Defines whether this extension is enabled */
  78443. enabled: boolean;
  78444. /** Defines whether this extension is required */
  78445. required: boolean;
  78446. /** Reference to the glTF exporter */
  78447. private _textureInfos;
  78448. private _exportedTextures;
  78449. private _wasUsed;
  78450. constructor(exporter: _Exporter);
  78451. dispose(): void;
  78452. /** @hidden */
  78453. get wasUsed(): boolean;
  78454. private _getTextureIndex;
  78455. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78456. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78457. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78458. }
  78459. }
  78460. declare module BABYLON {
  78461. /**
  78462. * Class for generating STL data from a Babylon scene.
  78463. */
  78464. export class STLExport {
  78465. /**
  78466. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78467. * @param meshes list defines the mesh to serialize
  78468. * @param download triggers the automatic download of the file.
  78469. * @param fileName changes the downloads fileName.
  78470. * @param binary changes the STL to a binary type.
  78471. * @param isLittleEndian toggle for binary type exporter.
  78472. * @returns the STL as UTF8 string
  78473. */
  78474. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78475. }
  78476. }
  78477. declare module "babylonjs-gltf2interface" {
  78478. export = BABYLON.GLTF2;
  78479. }
  78480. /**
  78481. * Module for glTF 2.0 Interface
  78482. */
  78483. declare module BABYLON.GLTF2 {
  78484. /**
  78485. * The datatype of the components in the attribute
  78486. */
  78487. const enum AccessorComponentType {
  78488. /**
  78489. * Byte
  78490. */
  78491. BYTE = 5120,
  78492. /**
  78493. * Unsigned Byte
  78494. */
  78495. UNSIGNED_BYTE = 5121,
  78496. /**
  78497. * Short
  78498. */
  78499. SHORT = 5122,
  78500. /**
  78501. * Unsigned Short
  78502. */
  78503. UNSIGNED_SHORT = 5123,
  78504. /**
  78505. * Unsigned Int
  78506. */
  78507. UNSIGNED_INT = 5125,
  78508. /**
  78509. * Float
  78510. */
  78511. FLOAT = 5126,
  78512. }
  78513. /**
  78514. * Specifies if the attirbute is a scalar, vector, or matrix
  78515. */
  78516. const enum AccessorType {
  78517. /**
  78518. * Scalar
  78519. */
  78520. SCALAR = "SCALAR",
  78521. /**
  78522. * Vector2
  78523. */
  78524. VEC2 = "VEC2",
  78525. /**
  78526. * Vector3
  78527. */
  78528. VEC3 = "VEC3",
  78529. /**
  78530. * Vector4
  78531. */
  78532. VEC4 = "VEC4",
  78533. /**
  78534. * Matrix2x2
  78535. */
  78536. MAT2 = "MAT2",
  78537. /**
  78538. * Matrix3x3
  78539. */
  78540. MAT3 = "MAT3",
  78541. /**
  78542. * Matrix4x4
  78543. */
  78544. MAT4 = "MAT4",
  78545. }
  78546. /**
  78547. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78548. */
  78549. const enum AnimationChannelTargetPath {
  78550. /**
  78551. * Translation
  78552. */
  78553. TRANSLATION = "translation",
  78554. /**
  78555. * Rotation
  78556. */
  78557. ROTATION = "rotation",
  78558. /**
  78559. * Scale
  78560. */
  78561. SCALE = "scale",
  78562. /**
  78563. * Weights
  78564. */
  78565. WEIGHTS = "weights",
  78566. }
  78567. /**
  78568. * Interpolation algorithm
  78569. */
  78570. const enum AnimationSamplerInterpolation {
  78571. /**
  78572. * The animated values are linearly interpolated between keyframes
  78573. */
  78574. LINEAR = "LINEAR",
  78575. /**
  78576. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78577. */
  78578. STEP = "STEP",
  78579. /**
  78580. * The animation's interpolation is computed using a cubic spline with specified tangents
  78581. */
  78582. CUBICSPLINE = "CUBICSPLINE",
  78583. }
  78584. /**
  78585. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78586. */
  78587. const enum CameraType {
  78588. /**
  78589. * A perspective camera containing properties to create a perspective projection matrix
  78590. */
  78591. PERSPECTIVE = "perspective",
  78592. /**
  78593. * An orthographic camera containing properties to create an orthographic projection matrix
  78594. */
  78595. ORTHOGRAPHIC = "orthographic",
  78596. }
  78597. /**
  78598. * The mime-type of the image
  78599. */
  78600. const enum ImageMimeType {
  78601. /**
  78602. * JPEG Mime-type
  78603. */
  78604. JPEG = "image/jpeg",
  78605. /**
  78606. * PNG Mime-type
  78607. */
  78608. PNG = "image/png",
  78609. }
  78610. /**
  78611. * The alpha rendering mode of the material
  78612. */
  78613. const enum MaterialAlphaMode {
  78614. /**
  78615. * The alpha value is ignored and the rendered output is fully opaque
  78616. */
  78617. OPAQUE = "OPAQUE",
  78618. /**
  78619. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78620. */
  78621. MASK = "MASK",
  78622. /**
  78623. * 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)
  78624. */
  78625. BLEND = "BLEND",
  78626. }
  78627. /**
  78628. * The type of the primitives to render
  78629. */
  78630. const enum MeshPrimitiveMode {
  78631. /**
  78632. * Points
  78633. */
  78634. POINTS = 0,
  78635. /**
  78636. * Lines
  78637. */
  78638. LINES = 1,
  78639. /**
  78640. * Line Loop
  78641. */
  78642. LINE_LOOP = 2,
  78643. /**
  78644. * Line Strip
  78645. */
  78646. LINE_STRIP = 3,
  78647. /**
  78648. * Triangles
  78649. */
  78650. TRIANGLES = 4,
  78651. /**
  78652. * Triangle Strip
  78653. */
  78654. TRIANGLE_STRIP = 5,
  78655. /**
  78656. * Triangle Fan
  78657. */
  78658. TRIANGLE_FAN = 6,
  78659. }
  78660. /**
  78661. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78662. */
  78663. const enum TextureMagFilter {
  78664. /**
  78665. * Nearest
  78666. */
  78667. NEAREST = 9728,
  78668. /**
  78669. * Linear
  78670. */
  78671. LINEAR = 9729,
  78672. }
  78673. /**
  78674. * Minification filter. All valid values correspond to WebGL enums
  78675. */
  78676. const enum TextureMinFilter {
  78677. /**
  78678. * Nearest
  78679. */
  78680. NEAREST = 9728,
  78681. /**
  78682. * Linear
  78683. */
  78684. LINEAR = 9729,
  78685. /**
  78686. * Nearest Mip-Map Nearest
  78687. */
  78688. NEAREST_MIPMAP_NEAREST = 9984,
  78689. /**
  78690. * Linear Mipmap Nearest
  78691. */
  78692. LINEAR_MIPMAP_NEAREST = 9985,
  78693. /**
  78694. * Nearest Mipmap Linear
  78695. */
  78696. NEAREST_MIPMAP_LINEAR = 9986,
  78697. /**
  78698. * Linear Mipmap Linear
  78699. */
  78700. LINEAR_MIPMAP_LINEAR = 9987,
  78701. }
  78702. /**
  78703. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78704. */
  78705. const enum TextureWrapMode {
  78706. /**
  78707. * Clamp to Edge
  78708. */
  78709. CLAMP_TO_EDGE = 33071,
  78710. /**
  78711. * Mirrored Repeat
  78712. */
  78713. MIRRORED_REPEAT = 33648,
  78714. /**
  78715. * Repeat
  78716. */
  78717. REPEAT = 10497,
  78718. }
  78719. /**
  78720. * glTF Property
  78721. */
  78722. interface IProperty {
  78723. /**
  78724. * Dictionary object with extension-specific objects
  78725. */
  78726. extensions?: {
  78727. [key: string]: any;
  78728. };
  78729. /**
  78730. * Application-Specific data
  78731. */
  78732. extras?: any;
  78733. }
  78734. /**
  78735. * glTF Child of Root Property
  78736. */
  78737. interface IChildRootProperty extends IProperty {
  78738. /**
  78739. * The user-defined name of this object
  78740. */
  78741. name?: string;
  78742. }
  78743. /**
  78744. * Indices of those attributes that deviate from their initialization value
  78745. */
  78746. interface IAccessorSparseIndices extends IProperty {
  78747. /**
  78748. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78749. */
  78750. bufferView: number;
  78751. /**
  78752. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78753. */
  78754. byteOffset?: number;
  78755. /**
  78756. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78757. */
  78758. componentType: AccessorComponentType;
  78759. }
  78760. /**
  78761. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78762. */
  78763. interface IAccessorSparseValues extends IProperty {
  78764. /**
  78765. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78766. */
  78767. bufferView: number;
  78768. /**
  78769. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78770. */
  78771. byteOffset?: number;
  78772. }
  78773. /**
  78774. * Sparse storage of attributes that deviate from their initialization value
  78775. */
  78776. interface IAccessorSparse extends IProperty {
  78777. /**
  78778. * The number of attributes encoded in this sparse accessor
  78779. */
  78780. count: number;
  78781. /**
  78782. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78783. */
  78784. indices: IAccessorSparseIndices;
  78785. /**
  78786. * 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
  78787. */
  78788. values: IAccessorSparseValues;
  78789. }
  78790. /**
  78791. * 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
  78792. */
  78793. interface IAccessor extends IChildRootProperty {
  78794. /**
  78795. * The index of the bufferview
  78796. */
  78797. bufferView?: number;
  78798. /**
  78799. * The offset relative to the start of the bufferView in bytes
  78800. */
  78801. byteOffset?: number;
  78802. /**
  78803. * The datatype of components in the attribute
  78804. */
  78805. componentType: AccessorComponentType;
  78806. /**
  78807. * Specifies whether integer data values should be normalized
  78808. */
  78809. normalized?: boolean;
  78810. /**
  78811. * The number of attributes referenced by this accessor
  78812. */
  78813. count: number;
  78814. /**
  78815. * Specifies if the attribute is a scalar, vector, or matrix
  78816. */
  78817. type: AccessorType;
  78818. /**
  78819. * Maximum value of each component in this attribute
  78820. */
  78821. max?: number[];
  78822. /**
  78823. * Minimum value of each component in this attribute
  78824. */
  78825. min?: number[];
  78826. /**
  78827. * Sparse storage of attributes that deviate from their initialization value
  78828. */
  78829. sparse?: IAccessorSparse;
  78830. }
  78831. /**
  78832. * Targets an animation's sampler at a node's property
  78833. */
  78834. interface IAnimationChannel extends IProperty {
  78835. /**
  78836. * The index of a sampler in this animation used to compute the value for the target
  78837. */
  78838. sampler: number;
  78839. /**
  78840. * The index of the node and TRS property to target
  78841. */
  78842. target: IAnimationChannelTarget;
  78843. }
  78844. /**
  78845. * The index of the node and TRS property that an animation channel targets
  78846. */
  78847. interface IAnimationChannelTarget extends IProperty {
  78848. /**
  78849. * The index of the node to target
  78850. */
  78851. node: number;
  78852. /**
  78853. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78854. */
  78855. path: AnimationChannelTargetPath;
  78856. }
  78857. /**
  78858. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78859. */
  78860. interface IAnimationSampler extends IProperty {
  78861. /**
  78862. * The index of an accessor containing keyframe input values, e.g., time
  78863. */
  78864. input: number;
  78865. /**
  78866. * Interpolation algorithm
  78867. */
  78868. interpolation?: AnimationSamplerInterpolation;
  78869. /**
  78870. * The index of an accessor, containing keyframe output values
  78871. */
  78872. output: number;
  78873. }
  78874. /**
  78875. * A keyframe animation
  78876. */
  78877. interface IAnimation extends IChildRootProperty {
  78878. /**
  78879. * An array of channels, each of which targets an animation's sampler at a node's property
  78880. */
  78881. channels: IAnimationChannel[];
  78882. /**
  78883. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78884. */
  78885. samplers: IAnimationSampler[];
  78886. }
  78887. /**
  78888. * Metadata about the glTF asset
  78889. */
  78890. interface IAsset extends IChildRootProperty {
  78891. /**
  78892. * A copyright message suitable for display to credit the content creator
  78893. */
  78894. copyright?: string;
  78895. /**
  78896. * Tool that generated this glTF model. Useful for debugging
  78897. */
  78898. generator?: string;
  78899. /**
  78900. * The glTF version that this asset targets
  78901. */
  78902. version: string;
  78903. /**
  78904. * The minimum glTF version that this asset targets
  78905. */
  78906. minVersion?: string;
  78907. }
  78908. /**
  78909. * A buffer points to binary geometry, animation, or skins
  78910. */
  78911. interface IBuffer extends IChildRootProperty {
  78912. /**
  78913. * 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
  78914. */
  78915. uri?: string;
  78916. /**
  78917. * The length of the buffer in bytes
  78918. */
  78919. byteLength: number;
  78920. }
  78921. /**
  78922. * A view into a buffer generally representing a subset of the buffer
  78923. */
  78924. interface IBufferView extends IChildRootProperty {
  78925. /**
  78926. * The index of the buffer
  78927. */
  78928. buffer: number;
  78929. /**
  78930. * The offset into the buffer in bytes
  78931. */
  78932. byteOffset?: number;
  78933. /**
  78934. * The lenth of the bufferView in bytes
  78935. */
  78936. byteLength: number;
  78937. /**
  78938. * The stride, in bytes
  78939. */
  78940. byteStride?: number;
  78941. }
  78942. /**
  78943. * An orthographic camera containing properties to create an orthographic projection matrix
  78944. */
  78945. interface ICameraOrthographic extends IProperty {
  78946. /**
  78947. * The floating-point horizontal magnification of the view. Must not be zero
  78948. */
  78949. xmag: number;
  78950. /**
  78951. * The floating-point vertical magnification of the view. Must not be zero
  78952. */
  78953. ymag: number;
  78954. /**
  78955. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78956. */
  78957. zfar: number;
  78958. /**
  78959. * The floating-point distance to the near clipping plane
  78960. */
  78961. znear: number;
  78962. }
  78963. /**
  78964. * A perspective camera containing properties to create a perspective projection matrix
  78965. */
  78966. interface ICameraPerspective extends IProperty {
  78967. /**
  78968. * The floating-point aspect ratio of the field of view
  78969. */
  78970. aspectRatio?: number;
  78971. /**
  78972. * The floating-point vertical field of view in radians
  78973. */
  78974. yfov: number;
  78975. /**
  78976. * The floating-point distance to the far clipping plane
  78977. */
  78978. zfar?: number;
  78979. /**
  78980. * The floating-point distance to the near clipping plane
  78981. */
  78982. znear: number;
  78983. }
  78984. /**
  78985. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78986. */
  78987. interface ICamera extends IChildRootProperty {
  78988. /**
  78989. * An orthographic camera containing properties to create an orthographic projection matrix
  78990. */
  78991. orthographic?: ICameraOrthographic;
  78992. /**
  78993. * A perspective camera containing properties to create a perspective projection matrix
  78994. */
  78995. perspective?: ICameraPerspective;
  78996. /**
  78997. * Specifies if the camera uses a perspective or orthographic projection
  78998. */
  78999. type: CameraType;
  79000. }
  79001. /**
  79002. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79003. */
  79004. interface IImage extends IChildRootProperty {
  79005. /**
  79006. * 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
  79007. */
  79008. uri?: string;
  79009. /**
  79010. * The image's MIME type
  79011. */
  79012. mimeType?: ImageMimeType;
  79013. /**
  79014. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79015. */
  79016. bufferView?: number;
  79017. }
  79018. /**
  79019. * Material Normal Texture Info
  79020. */
  79021. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79022. /**
  79023. * The scalar multiplier applied to each normal vector of the normal texture
  79024. */
  79025. scale?: number;
  79026. }
  79027. /**
  79028. * Material Occlusion Texture Info
  79029. */
  79030. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79031. /**
  79032. * A scalar multiplier controlling the amount of occlusion applied
  79033. */
  79034. strength?: number;
  79035. }
  79036. /**
  79037. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79038. */
  79039. interface IMaterialPbrMetallicRoughness {
  79040. /**
  79041. * The material's base color factor
  79042. */
  79043. baseColorFactor?: number[];
  79044. /**
  79045. * The base color texture
  79046. */
  79047. baseColorTexture?: ITextureInfo;
  79048. /**
  79049. * The metalness of the material
  79050. */
  79051. metallicFactor?: number;
  79052. /**
  79053. * The roughness of the material
  79054. */
  79055. roughnessFactor?: number;
  79056. /**
  79057. * The metallic-roughness texture
  79058. */
  79059. metallicRoughnessTexture?: ITextureInfo;
  79060. }
  79061. /**
  79062. * The material appearance of a primitive
  79063. */
  79064. interface IMaterial extends IChildRootProperty {
  79065. /**
  79066. * 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
  79067. */
  79068. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79069. /**
  79070. * The normal map texture
  79071. */
  79072. normalTexture?: IMaterialNormalTextureInfo;
  79073. /**
  79074. * The occlusion map texture
  79075. */
  79076. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79077. /**
  79078. * The emissive map texture
  79079. */
  79080. emissiveTexture?: ITextureInfo;
  79081. /**
  79082. * 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
  79083. */
  79084. emissiveFactor?: number[];
  79085. /**
  79086. * The alpha rendering mode of the material
  79087. */
  79088. alphaMode?: MaterialAlphaMode;
  79089. /**
  79090. * The alpha cutoff value of the material
  79091. */
  79092. alphaCutoff?: number;
  79093. /**
  79094. * Specifies whether the material is double sided
  79095. */
  79096. doubleSided?: boolean;
  79097. }
  79098. /**
  79099. * Geometry to be rendered with the given material
  79100. */
  79101. interface IMeshPrimitive extends IProperty {
  79102. /**
  79103. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79104. */
  79105. attributes: {
  79106. [name: string]: number;
  79107. };
  79108. /**
  79109. * The index of the accessor that contains the indices
  79110. */
  79111. indices?: number;
  79112. /**
  79113. * The index of the material to apply to this primitive when rendering
  79114. */
  79115. material?: number;
  79116. /**
  79117. * The type of primitives to render. All valid values correspond to WebGL enums
  79118. */
  79119. mode?: MeshPrimitiveMode;
  79120. /**
  79121. * 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
  79122. */
  79123. targets?: {
  79124. [name: string]: number;
  79125. }[];
  79126. }
  79127. /**
  79128. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79129. */
  79130. interface IMesh extends IChildRootProperty {
  79131. /**
  79132. * An array of primitives, each defining geometry to be rendered with a material
  79133. */
  79134. primitives: IMeshPrimitive[];
  79135. /**
  79136. * Array of weights to be applied to the Morph Targets
  79137. */
  79138. weights?: number[];
  79139. }
  79140. /**
  79141. * A node in the node hierarchy
  79142. */
  79143. interface INode extends IChildRootProperty {
  79144. /**
  79145. * The index of the camera referenced by this node
  79146. */
  79147. camera?: number;
  79148. /**
  79149. * The indices of this node's children
  79150. */
  79151. children?: number[];
  79152. /**
  79153. * The index of the skin referenced by this node
  79154. */
  79155. skin?: number;
  79156. /**
  79157. * A floating-point 4x4 transformation matrix stored in column-major order
  79158. */
  79159. matrix?: number[];
  79160. /**
  79161. * The index of the mesh in this node
  79162. */
  79163. mesh?: number;
  79164. /**
  79165. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79166. */
  79167. rotation?: number[];
  79168. /**
  79169. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79170. */
  79171. scale?: number[];
  79172. /**
  79173. * The node's translation along the x, y, and z axes
  79174. */
  79175. translation?: number[];
  79176. /**
  79177. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79178. */
  79179. weights?: number[];
  79180. }
  79181. /**
  79182. * Texture sampler properties for filtering and wrapping modes
  79183. */
  79184. interface ISampler extends IChildRootProperty {
  79185. /**
  79186. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79187. */
  79188. magFilter?: TextureMagFilter;
  79189. /**
  79190. * Minification filter. All valid values correspond to WebGL enums
  79191. */
  79192. minFilter?: TextureMinFilter;
  79193. /**
  79194. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79195. */
  79196. wrapS?: TextureWrapMode;
  79197. /**
  79198. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79199. */
  79200. wrapT?: TextureWrapMode;
  79201. }
  79202. /**
  79203. * The root nodes of a scene
  79204. */
  79205. interface IScene extends IChildRootProperty {
  79206. /**
  79207. * The indices of each root node
  79208. */
  79209. nodes: number[];
  79210. }
  79211. /**
  79212. * Joints and matrices defining a skin
  79213. */
  79214. interface ISkin extends IChildRootProperty {
  79215. /**
  79216. * 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
  79217. */
  79218. inverseBindMatrices?: number;
  79219. /**
  79220. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79221. */
  79222. skeleton?: number;
  79223. /**
  79224. * 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)
  79225. */
  79226. joints: number[];
  79227. }
  79228. /**
  79229. * A texture and its sampler
  79230. */
  79231. interface ITexture extends IChildRootProperty {
  79232. /**
  79233. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79234. */
  79235. sampler?: number;
  79236. /**
  79237. * The index of the image used by this texture
  79238. */
  79239. source: number;
  79240. }
  79241. /**
  79242. * Reference to a texture
  79243. */
  79244. interface ITextureInfo extends IProperty {
  79245. /**
  79246. * The index of the texture
  79247. */
  79248. index: number;
  79249. /**
  79250. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79251. */
  79252. texCoord?: number;
  79253. }
  79254. /**
  79255. * The root object for a glTF asset
  79256. */
  79257. interface IGLTF extends IProperty {
  79258. /**
  79259. * An array of accessors. An accessor is a typed view into a bufferView
  79260. */
  79261. accessors?: IAccessor[];
  79262. /**
  79263. * An array of keyframe animations
  79264. */
  79265. animations?: IAnimation[];
  79266. /**
  79267. * Metadata about the glTF asset
  79268. */
  79269. asset: IAsset;
  79270. /**
  79271. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79272. */
  79273. buffers?: IBuffer[];
  79274. /**
  79275. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79276. */
  79277. bufferViews?: IBufferView[];
  79278. /**
  79279. * An array of cameras
  79280. */
  79281. cameras?: ICamera[];
  79282. /**
  79283. * Names of glTF extensions used somewhere in this asset
  79284. */
  79285. extensionsUsed?: string[];
  79286. /**
  79287. * Names of glTF extensions required to properly load this asset
  79288. */
  79289. extensionsRequired?: string[];
  79290. /**
  79291. * An array of images. An image defines data used to create a texture
  79292. */
  79293. images?: IImage[];
  79294. /**
  79295. * An array of materials. A material defines the appearance of a primitive
  79296. */
  79297. materials?: IMaterial[];
  79298. /**
  79299. * An array of meshes. A mesh is a set of primitives to be rendered
  79300. */
  79301. meshes?: IMesh[];
  79302. /**
  79303. * An array of nodes
  79304. */
  79305. nodes?: INode[];
  79306. /**
  79307. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79308. */
  79309. samplers?: ISampler[];
  79310. /**
  79311. * The index of the default scene
  79312. */
  79313. scene?: number;
  79314. /**
  79315. * An array of scenes
  79316. */
  79317. scenes?: IScene[];
  79318. /**
  79319. * An array of skins. A skin is defined by joints and matrices
  79320. */
  79321. skins?: ISkin[];
  79322. /**
  79323. * An array of textures
  79324. */
  79325. textures?: ITexture[];
  79326. }
  79327. /**
  79328. * The glTF validation results
  79329. * @ignore
  79330. */
  79331. interface IGLTFValidationResults {
  79332. info: {
  79333. generator: string;
  79334. hasAnimations: boolean;
  79335. hasDefaultScene: boolean;
  79336. hasMaterials: boolean;
  79337. hasMorphTargets: boolean;
  79338. hasSkins: boolean;
  79339. hasTextures: boolean;
  79340. maxAttributesUsed: number;
  79341. primitivesCount: number
  79342. };
  79343. issues: {
  79344. messages: Array<string>;
  79345. numErrors: number;
  79346. numHints: number;
  79347. numInfos: number;
  79348. numWarnings: number;
  79349. truncated: boolean
  79350. };
  79351. mimeType: string;
  79352. uri: string;
  79353. validatedAt: string;
  79354. validatorVersion: string;
  79355. }
  79356. /**
  79357. * The glTF validation options
  79358. */
  79359. interface IGLTFValidationOptions {
  79360. /** Uri to use */
  79361. uri?: string;
  79362. /** Function used to load external resources */
  79363. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79364. /** Boolean indicating that we need to validate accessor data */
  79365. validateAccessorData?: boolean;
  79366. /** max number of issues allowed */
  79367. maxIssues?: number;
  79368. /** Ignored issues */
  79369. ignoredIssues?: Array<string>;
  79370. /** Value to override severy settings */
  79371. severityOverrides?: Object;
  79372. }
  79373. /**
  79374. * The glTF validator object
  79375. * @ignore
  79376. */
  79377. interface IGLTFValidator {
  79378. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79379. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79380. }
  79381. }
  79382. declare module BABYLON {
  79383. /** @hidden */
  79384. export var cellPixelShader: {
  79385. name: string;
  79386. shader: string;
  79387. };
  79388. }
  79389. declare module BABYLON {
  79390. /** @hidden */
  79391. export var cellVertexShader: {
  79392. name: string;
  79393. shader: string;
  79394. };
  79395. }
  79396. declare module BABYLON {
  79397. export class CellMaterial extends BABYLON.PushMaterial {
  79398. private _diffuseTexture;
  79399. diffuseTexture: BABYLON.BaseTexture;
  79400. diffuseColor: BABYLON.Color3;
  79401. _computeHighLevel: boolean;
  79402. computeHighLevel: boolean;
  79403. private _disableLighting;
  79404. disableLighting: boolean;
  79405. private _maxSimultaneousLights;
  79406. maxSimultaneousLights: number;
  79407. private _renderId;
  79408. constructor(name: string, scene: BABYLON.Scene);
  79409. needAlphaBlending(): boolean;
  79410. needAlphaTesting(): boolean;
  79411. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79412. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79413. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79414. getAnimatables(): BABYLON.IAnimatable[];
  79415. getActiveTextures(): BABYLON.BaseTexture[];
  79416. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79417. dispose(forceDisposeEffect?: boolean): void;
  79418. getClassName(): string;
  79419. clone(name: string): CellMaterial;
  79420. serialize(): any;
  79421. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79422. }
  79423. }
  79424. declare module BABYLON {
  79425. export class CustomShaderStructure {
  79426. FragmentStore: string;
  79427. VertexStore: string;
  79428. constructor();
  79429. }
  79430. export class ShaderSpecialParts {
  79431. constructor();
  79432. Fragment_Begin: string;
  79433. Fragment_Definitions: string;
  79434. Fragment_MainBegin: string;
  79435. Fragment_Custom_Diffuse: string;
  79436. Fragment_Before_Lights: string;
  79437. Fragment_Before_Fog: string;
  79438. Fragment_Custom_Alpha: string;
  79439. Fragment_Before_FragColor: string;
  79440. Vertex_Begin: string;
  79441. Vertex_Definitions: string;
  79442. Vertex_MainBegin: string;
  79443. Vertex_Before_PositionUpdated: string;
  79444. Vertex_Before_NormalUpdated: string;
  79445. Vertex_MainEnd: string;
  79446. }
  79447. export class CustomMaterial extends BABYLON.StandardMaterial {
  79448. static ShaderIndexer: number;
  79449. CustomParts: ShaderSpecialParts;
  79450. _isCreatedShader: boolean;
  79451. _createdShaderName: string;
  79452. _customUniform: string[];
  79453. _newUniforms: string[];
  79454. _newUniformInstances: any[];
  79455. _newSamplerInstances: BABYLON.Texture[];
  79456. _customAttributes: string[];
  79457. FragmentShader: string;
  79458. VertexShader: string;
  79459. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79460. ReviewUniform(name: string, arr: string[]): string[];
  79461. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79462. constructor(name: string, scene: BABYLON.Scene);
  79463. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79464. AddAttribute(name: string): CustomMaterial;
  79465. Fragment_Begin(shaderPart: string): CustomMaterial;
  79466. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79467. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79468. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79469. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79470. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79471. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79472. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79473. Vertex_Begin(shaderPart: string): CustomMaterial;
  79474. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79475. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79476. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79477. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79478. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79479. }
  79480. }
  79481. declare module BABYLON {
  79482. export class ShaderAlebdoParts {
  79483. constructor();
  79484. Fragment_Begin: string;
  79485. Fragment_Definitions: string;
  79486. Fragment_MainBegin: string;
  79487. Fragment_Custom_Albedo: string;
  79488. Fragment_Before_Lights: string;
  79489. Fragment_Custom_MetallicRoughness: string;
  79490. Fragment_Custom_MicroSurface: string;
  79491. Fragment_Before_Fog: string;
  79492. Fragment_Custom_Alpha: string;
  79493. Fragment_Before_FragColor: string;
  79494. Vertex_Begin: string;
  79495. Vertex_Definitions: string;
  79496. Vertex_MainBegin: string;
  79497. Vertex_Before_PositionUpdated: string;
  79498. Vertex_Before_NormalUpdated: string;
  79499. Vertex_MainEnd: string;
  79500. }
  79501. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79502. static ShaderIndexer: number;
  79503. CustomParts: ShaderAlebdoParts;
  79504. _isCreatedShader: boolean;
  79505. _createdShaderName: string;
  79506. _customUniform: string[];
  79507. _newUniforms: string[];
  79508. _newUniformInstances: any[];
  79509. _newSamplerInstances: BABYLON.Texture[];
  79510. _customAttributes: string[];
  79511. FragmentShader: string;
  79512. VertexShader: string;
  79513. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79514. ReviewUniform(name: string, arr: string[]): string[];
  79515. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79516. constructor(name: string, scene: BABYLON.Scene);
  79517. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79518. AddAttribute(name: string): PBRCustomMaterial;
  79519. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79520. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79521. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79522. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79523. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79524. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79525. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79526. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79527. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79528. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79529. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79530. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79531. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79532. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79533. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79534. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79535. }
  79536. }
  79537. declare module BABYLON {
  79538. /** @hidden */
  79539. export var firePixelShader: {
  79540. name: string;
  79541. shader: string;
  79542. };
  79543. }
  79544. declare module BABYLON {
  79545. /** @hidden */
  79546. export var fireVertexShader: {
  79547. name: string;
  79548. shader: string;
  79549. };
  79550. }
  79551. declare module BABYLON {
  79552. export class FireMaterial extends BABYLON.PushMaterial {
  79553. private _diffuseTexture;
  79554. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79555. private _distortionTexture;
  79556. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79557. private _opacityTexture;
  79558. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79559. diffuseColor: BABYLON.Color3;
  79560. speed: number;
  79561. private _scaledDiffuse;
  79562. private _renderId;
  79563. private _lastTime;
  79564. constructor(name: string, scene: BABYLON.Scene);
  79565. needAlphaBlending(): boolean;
  79566. needAlphaTesting(): boolean;
  79567. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79568. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79569. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79570. getAnimatables(): BABYLON.IAnimatable[];
  79571. getActiveTextures(): BABYLON.BaseTexture[];
  79572. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79573. getClassName(): string;
  79574. dispose(forceDisposeEffect?: boolean): void;
  79575. clone(name: string): FireMaterial;
  79576. serialize(): any;
  79577. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79578. }
  79579. }
  79580. declare module BABYLON {
  79581. /** @hidden */
  79582. export var furPixelShader: {
  79583. name: string;
  79584. shader: string;
  79585. };
  79586. }
  79587. declare module BABYLON {
  79588. /** @hidden */
  79589. export var furVertexShader: {
  79590. name: string;
  79591. shader: string;
  79592. };
  79593. }
  79594. declare module BABYLON {
  79595. export class FurMaterial extends BABYLON.PushMaterial {
  79596. private _diffuseTexture;
  79597. diffuseTexture: BABYLON.BaseTexture;
  79598. private _heightTexture;
  79599. heightTexture: BABYLON.BaseTexture;
  79600. diffuseColor: BABYLON.Color3;
  79601. furLength: number;
  79602. furAngle: number;
  79603. furColor: BABYLON.Color3;
  79604. furOffset: number;
  79605. furSpacing: number;
  79606. furGravity: BABYLON.Vector3;
  79607. furSpeed: number;
  79608. furDensity: number;
  79609. furOcclusion: number;
  79610. furTexture: BABYLON.DynamicTexture;
  79611. private _disableLighting;
  79612. disableLighting: boolean;
  79613. private _maxSimultaneousLights;
  79614. maxSimultaneousLights: number;
  79615. highLevelFur: boolean;
  79616. _meshes: BABYLON.AbstractMesh[];
  79617. private _renderId;
  79618. private _furTime;
  79619. constructor(name: string, scene: BABYLON.Scene);
  79620. get furTime(): number;
  79621. set furTime(furTime: number);
  79622. needAlphaBlending(): boolean;
  79623. needAlphaTesting(): boolean;
  79624. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79625. updateFur(): void;
  79626. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79627. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79628. getAnimatables(): BABYLON.IAnimatable[];
  79629. getActiveTextures(): BABYLON.BaseTexture[];
  79630. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79631. dispose(forceDisposeEffect?: boolean): void;
  79632. clone(name: string): FurMaterial;
  79633. serialize(): any;
  79634. getClassName(): string;
  79635. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79636. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79637. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79638. }
  79639. }
  79640. declare module BABYLON {
  79641. /** @hidden */
  79642. export var gradientPixelShader: {
  79643. name: string;
  79644. shader: string;
  79645. };
  79646. }
  79647. declare module BABYLON {
  79648. /** @hidden */
  79649. export var gradientVertexShader: {
  79650. name: string;
  79651. shader: string;
  79652. };
  79653. }
  79654. declare module BABYLON {
  79655. export class GradientMaterial extends BABYLON.PushMaterial {
  79656. private _maxSimultaneousLights;
  79657. maxSimultaneousLights: number;
  79658. topColor: BABYLON.Color3;
  79659. topColorAlpha: number;
  79660. bottomColor: BABYLON.Color3;
  79661. bottomColorAlpha: number;
  79662. offset: number;
  79663. scale: number;
  79664. smoothness: number;
  79665. private _disableLighting;
  79666. disableLighting: boolean;
  79667. private _renderId;
  79668. constructor(name: string, scene: BABYLON.Scene);
  79669. needAlphaBlending(): boolean;
  79670. needAlphaTesting(): boolean;
  79671. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79672. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79673. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79674. getAnimatables(): BABYLON.IAnimatable[];
  79675. dispose(forceDisposeEffect?: boolean): void;
  79676. clone(name: string): GradientMaterial;
  79677. serialize(): any;
  79678. getClassName(): string;
  79679. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79680. }
  79681. }
  79682. declare module BABYLON {
  79683. /** @hidden */
  79684. export var gridPixelShader: {
  79685. name: string;
  79686. shader: string;
  79687. };
  79688. }
  79689. declare module BABYLON {
  79690. /** @hidden */
  79691. export var gridVertexShader: {
  79692. name: string;
  79693. shader: string;
  79694. };
  79695. }
  79696. declare module BABYLON {
  79697. /**
  79698. * The grid materials allows you to wrap any shape with a grid.
  79699. * Colors are customizable.
  79700. */
  79701. export class GridMaterial extends BABYLON.PushMaterial {
  79702. /**
  79703. * Main color of the grid (e.g. between lines)
  79704. */
  79705. mainColor: BABYLON.Color3;
  79706. /**
  79707. * Color of the grid lines.
  79708. */
  79709. lineColor: BABYLON.Color3;
  79710. /**
  79711. * The scale of the grid compared to unit.
  79712. */
  79713. gridRatio: number;
  79714. /**
  79715. * Allows setting an offset for the grid lines.
  79716. */
  79717. gridOffset: BABYLON.Vector3;
  79718. /**
  79719. * The frequency of thicker lines.
  79720. */
  79721. majorUnitFrequency: number;
  79722. /**
  79723. * The visibility of minor units in the grid.
  79724. */
  79725. minorUnitVisibility: number;
  79726. /**
  79727. * The grid opacity outside of the lines.
  79728. */
  79729. opacity: number;
  79730. /**
  79731. * Determine RBG output is premultiplied by alpha value.
  79732. */
  79733. preMultiplyAlpha: boolean;
  79734. private _opacityTexture;
  79735. opacityTexture: BABYLON.BaseTexture;
  79736. private _gridControl;
  79737. private _renderId;
  79738. /**
  79739. * constructor
  79740. * @param name The name given to the material in order to identify it afterwards.
  79741. * @param scene The scene the material is used in.
  79742. */
  79743. constructor(name: string, scene: BABYLON.Scene);
  79744. /**
  79745. * Returns wehter or not the grid requires alpha blending.
  79746. */
  79747. needAlphaBlending(): boolean;
  79748. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79749. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79750. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79751. /**
  79752. * Dispose the material and its associated resources.
  79753. * @param forceDisposeEffect will also dispose the used effect when true
  79754. */
  79755. dispose(forceDisposeEffect?: boolean): void;
  79756. clone(name: string): GridMaterial;
  79757. serialize(): any;
  79758. getClassName(): string;
  79759. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79760. }
  79761. }
  79762. declare module BABYLON {
  79763. /** @hidden */
  79764. export var lavaPixelShader: {
  79765. name: string;
  79766. shader: string;
  79767. };
  79768. }
  79769. declare module BABYLON {
  79770. /** @hidden */
  79771. export var lavaVertexShader: {
  79772. name: string;
  79773. shader: string;
  79774. };
  79775. }
  79776. declare module BABYLON {
  79777. export class LavaMaterial extends BABYLON.PushMaterial {
  79778. private _diffuseTexture;
  79779. diffuseTexture: BABYLON.BaseTexture;
  79780. noiseTexture: BABYLON.BaseTexture;
  79781. fogColor: BABYLON.Color3;
  79782. speed: number;
  79783. movingSpeed: number;
  79784. lowFrequencySpeed: number;
  79785. fogDensity: number;
  79786. private _lastTime;
  79787. diffuseColor: BABYLON.Color3;
  79788. private _disableLighting;
  79789. disableLighting: boolean;
  79790. private _unlit;
  79791. unlit: boolean;
  79792. private _maxSimultaneousLights;
  79793. maxSimultaneousLights: number;
  79794. private _scaledDiffuse;
  79795. private _renderId;
  79796. constructor(name: string, scene: BABYLON.Scene);
  79797. needAlphaBlending(): boolean;
  79798. needAlphaTesting(): boolean;
  79799. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79800. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79801. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79802. getAnimatables(): BABYLON.IAnimatable[];
  79803. getActiveTextures(): BABYLON.BaseTexture[];
  79804. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79805. dispose(forceDisposeEffect?: boolean): void;
  79806. clone(name: string): LavaMaterial;
  79807. serialize(): any;
  79808. getClassName(): string;
  79809. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79810. }
  79811. }
  79812. declare module BABYLON {
  79813. /** @hidden */
  79814. export var mixPixelShader: {
  79815. name: string;
  79816. shader: string;
  79817. };
  79818. }
  79819. declare module BABYLON {
  79820. /** @hidden */
  79821. export var mixVertexShader: {
  79822. name: string;
  79823. shader: string;
  79824. };
  79825. }
  79826. declare module BABYLON {
  79827. export class MixMaterial extends BABYLON.PushMaterial {
  79828. /**
  79829. * Mix textures
  79830. */
  79831. private _mixTexture1;
  79832. mixTexture1: BABYLON.BaseTexture;
  79833. private _mixTexture2;
  79834. mixTexture2: BABYLON.BaseTexture;
  79835. /**
  79836. * Diffuse textures
  79837. */
  79838. private _diffuseTexture1;
  79839. diffuseTexture1: BABYLON.Texture;
  79840. private _diffuseTexture2;
  79841. diffuseTexture2: BABYLON.Texture;
  79842. private _diffuseTexture3;
  79843. diffuseTexture3: BABYLON.Texture;
  79844. private _diffuseTexture4;
  79845. diffuseTexture4: BABYLON.Texture;
  79846. private _diffuseTexture5;
  79847. diffuseTexture5: BABYLON.Texture;
  79848. private _diffuseTexture6;
  79849. diffuseTexture6: BABYLON.Texture;
  79850. private _diffuseTexture7;
  79851. diffuseTexture7: BABYLON.Texture;
  79852. private _diffuseTexture8;
  79853. diffuseTexture8: BABYLON.Texture;
  79854. /**
  79855. * Uniforms
  79856. */
  79857. diffuseColor: BABYLON.Color3;
  79858. specularColor: BABYLON.Color3;
  79859. specularPower: number;
  79860. private _disableLighting;
  79861. disableLighting: boolean;
  79862. private _maxSimultaneousLights;
  79863. maxSimultaneousLights: number;
  79864. private _renderId;
  79865. constructor(name: string, scene: BABYLON.Scene);
  79866. needAlphaBlending(): boolean;
  79867. needAlphaTesting(): boolean;
  79868. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79871. getAnimatables(): BABYLON.IAnimatable[];
  79872. getActiveTextures(): BABYLON.BaseTexture[];
  79873. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79874. dispose(forceDisposeEffect?: boolean): void;
  79875. clone(name: string): MixMaterial;
  79876. serialize(): any;
  79877. getClassName(): string;
  79878. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79879. }
  79880. }
  79881. declare module BABYLON {
  79882. /** @hidden */
  79883. export var normalPixelShader: {
  79884. name: string;
  79885. shader: string;
  79886. };
  79887. }
  79888. declare module BABYLON {
  79889. /** @hidden */
  79890. export var normalVertexShader: {
  79891. name: string;
  79892. shader: string;
  79893. };
  79894. }
  79895. declare module BABYLON {
  79896. export class NormalMaterial extends BABYLON.PushMaterial {
  79897. private _diffuseTexture;
  79898. diffuseTexture: BABYLON.BaseTexture;
  79899. diffuseColor: BABYLON.Color3;
  79900. private _disableLighting;
  79901. disableLighting: boolean;
  79902. private _maxSimultaneousLights;
  79903. maxSimultaneousLights: number;
  79904. private _renderId;
  79905. constructor(name: string, scene: BABYLON.Scene);
  79906. needAlphaBlending(): boolean;
  79907. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79908. needAlphaTesting(): boolean;
  79909. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79912. getAnimatables(): BABYLON.IAnimatable[];
  79913. getActiveTextures(): BABYLON.BaseTexture[];
  79914. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79915. dispose(forceDisposeEffect?: boolean): void;
  79916. clone(name: string): NormalMaterial;
  79917. serialize(): any;
  79918. getClassName(): string;
  79919. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79920. }
  79921. }
  79922. declare module BABYLON {
  79923. /** @hidden */
  79924. export var shadowOnlyPixelShader: {
  79925. name: string;
  79926. shader: string;
  79927. };
  79928. }
  79929. declare module BABYLON {
  79930. /** @hidden */
  79931. export var shadowOnlyVertexShader: {
  79932. name: string;
  79933. shader: string;
  79934. };
  79935. }
  79936. declare module BABYLON {
  79937. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79938. private _renderId;
  79939. private _activeLight;
  79940. constructor(name: string, scene: BABYLON.Scene);
  79941. shadowColor: BABYLON.Color3;
  79942. needAlphaBlending(): boolean;
  79943. needAlphaTesting(): boolean;
  79944. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79945. get activeLight(): BABYLON.IShadowLight;
  79946. set activeLight(light: BABYLON.IShadowLight);
  79947. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79948. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79949. clone(name: string): ShadowOnlyMaterial;
  79950. serialize(): any;
  79951. getClassName(): string;
  79952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79953. }
  79954. }
  79955. declare module BABYLON {
  79956. /** @hidden */
  79957. export var simplePixelShader: {
  79958. name: string;
  79959. shader: string;
  79960. };
  79961. }
  79962. declare module BABYLON {
  79963. /** @hidden */
  79964. export var simpleVertexShader: {
  79965. name: string;
  79966. shader: string;
  79967. };
  79968. }
  79969. declare module BABYLON {
  79970. export class SimpleMaterial extends BABYLON.PushMaterial {
  79971. private _diffuseTexture;
  79972. diffuseTexture: BABYLON.BaseTexture;
  79973. diffuseColor: BABYLON.Color3;
  79974. private _disableLighting;
  79975. disableLighting: boolean;
  79976. private _maxSimultaneousLights;
  79977. maxSimultaneousLights: number;
  79978. private _renderId;
  79979. constructor(name: string, scene: BABYLON.Scene);
  79980. needAlphaBlending(): boolean;
  79981. needAlphaTesting(): boolean;
  79982. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79983. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79984. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79985. getAnimatables(): BABYLON.IAnimatable[];
  79986. getActiveTextures(): BABYLON.BaseTexture[];
  79987. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79988. dispose(forceDisposeEffect?: boolean): void;
  79989. clone(name: string): SimpleMaterial;
  79990. serialize(): any;
  79991. getClassName(): string;
  79992. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79993. }
  79994. }
  79995. declare module BABYLON {
  79996. /** @hidden */
  79997. export var skyPixelShader: {
  79998. name: string;
  79999. shader: string;
  80000. };
  80001. }
  80002. declare module BABYLON {
  80003. /** @hidden */
  80004. export var skyVertexShader: {
  80005. name: string;
  80006. shader: string;
  80007. };
  80008. }
  80009. declare module BABYLON {
  80010. /**
  80011. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80012. * @see https://doc.babylonjs.com/extensions/sky
  80013. */
  80014. export class SkyMaterial extends BABYLON.PushMaterial {
  80015. /**
  80016. * Defines the overall luminance of sky in interval ]0, 1[.
  80017. */
  80018. luminance: number;
  80019. /**
  80020. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80021. */
  80022. turbidity: number;
  80023. /**
  80024. * Defines the sky appearance (light intensity).
  80025. */
  80026. rayleigh: number;
  80027. /**
  80028. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80029. */
  80030. mieCoefficient: number;
  80031. /**
  80032. * Defines the amount of haze particles following the Mie scattering theory.
  80033. */
  80034. mieDirectionalG: number;
  80035. /**
  80036. * Defines the distance of the sun according to the active scene camera.
  80037. */
  80038. distance: number;
  80039. /**
  80040. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80041. * "inclined".
  80042. */
  80043. inclination: number;
  80044. /**
  80045. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80046. * an object direction and a reference direction.
  80047. */
  80048. azimuth: number;
  80049. /**
  80050. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80051. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80052. */
  80053. sunPosition: BABYLON.Vector3;
  80054. /**
  80055. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80056. * .sunPosition property.
  80057. */
  80058. useSunPosition: boolean;
  80059. /**
  80060. * Defines an offset vector used to get a horizon offset.
  80061. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80062. */
  80063. cameraOffset: BABYLON.Vector3;
  80064. private _cameraPosition;
  80065. private _renderId;
  80066. /**
  80067. * Instantiates a new sky material.
  80068. * This material allows to create dynamic and texture free
  80069. * effects for skyboxes by taking care of the atmosphere state.
  80070. * @see https://doc.babylonjs.com/extensions/sky
  80071. * @param name Define the name of the material in the scene
  80072. * @param scene Define the scene the material belong to
  80073. */
  80074. constructor(name: string, scene: BABYLON.Scene);
  80075. /**
  80076. * Specifies if the material will require alpha blending
  80077. * @returns a boolean specifying if alpha blending is needed
  80078. */
  80079. needAlphaBlending(): boolean;
  80080. /**
  80081. * Specifies if this material should be rendered in alpha test mode
  80082. * @returns false as the sky material doesn't need alpha testing.
  80083. */
  80084. needAlphaTesting(): boolean;
  80085. /**
  80086. * Get the texture used for alpha test purpose.
  80087. * @returns null as the sky material has no texture.
  80088. */
  80089. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80090. /**
  80091. * Get if the submesh is ready to be used and all its information available.
  80092. * Child classes can use it to update shaders
  80093. * @param mesh defines the mesh to check
  80094. * @param subMesh defines which submesh to check
  80095. * @param useInstances specifies that instances should be used
  80096. * @returns a boolean indicating that the submesh is ready or not
  80097. */
  80098. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80099. /**
  80100. * Binds the submesh to this material by preparing the effect and shader to draw
  80101. * @param world defines the world transformation matrix
  80102. * @param mesh defines the mesh containing the submesh
  80103. * @param subMesh defines the submesh to bind the material to
  80104. */
  80105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80106. /**
  80107. * Get the list of animatables in the material.
  80108. * @returns the list of animatables object used in the material
  80109. */
  80110. getAnimatables(): BABYLON.IAnimatable[];
  80111. /**
  80112. * Disposes the material
  80113. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80114. */
  80115. dispose(forceDisposeEffect?: boolean): void;
  80116. /**
  80117. * Makes a duplicate of the material, and gives it a new name
  80118. * @param name defines the new name for the duplicated material
  80119. * @returns the cloned material
  80120. */
  80121. clone(name: string): SkyMaterial;
  80122. /**
  80123. * Serializes this material in a JSON representation
  80124. * @returns the serialized material object
  80125. */
  80126. serialize(): any;
  80127. /**
  80128. * Gets the current class name of the material e.g. "SkyMaterial"
  80129. * Mainly use in serialization.
  80130. * @returns the class name
  80131. */
  80132. getClassName(): string;
  80133. /**
  80134. * Creates a sky material from parsed material data
  80135. * @param source defines the JSON representation of the material
  80136. * @param scene defines the hosting scene
  80137. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80138. * @returns a new sky material
  80139. */
  80140. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80141. }
  80142. }
  80143. declare module BABYLON {
  80144. /** @hidden */
  80145. export var terrainPixelShader: {
  80146. name: string;
  80147. shader: string;
  80148. };
  80149. }
  80150. declare module BABYLON {
  80151. /** @hidden */
  80152. export var terrainVertexShader: {
  80153. name: string;
  80154. shader: string;
  80155. };
  80156. }
  80157. declare module BABYLON {
  80158. export class TerrainMaterial extends BABYLON.PushMaterial {
  80159. private _mixTexture;
  80160. mixTexture: BABYLON.BaseTexture;
  80161. private _diffuseTexture1;
  80162. diffuseTexture1: BABYLON.Texture;
  80163. private _diffuseTexture2;
  80164. diffuseTexture2: BABYLON.Texture;
  80165. private _diffuseTexture3;
  80166. diffuseTexture3: BABYLON.Texture;
  80167. private _bumpTexture1;
  80168. bumpTexture1: BABYLON.Texture;
  80169. private _bumpTexture2;
  80170. bumpTexture2: BABYLON.Texture;
  80171. private _bumpTexture3;
  80172. bumpTexture3: BABYLON.Texture;
  80173. diffuseColor: BABYLON.Color3;
  80174. specularColor: BABYLON.Color3;
  80175. specularPower: number;
  80176. private _disableLighting;
  80177. disableLighting: boolean;
  80178. private _maxSimultaneousLights;
  80179. maxSimultaneousLights: number;
  80180. private _renderId;
  80181. constructor(name: string, scene: BABYLON.Scene);
  80182. needAlphaBlending(): boolean;
  80183. needAlphaTesting(): boolean;
  80184. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80185. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80186. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80187. getAnimatables(): BABYLON.IAnimatable[];
  80188. getActiveTextures(): BABYLON.BaseTexture[];
  80189. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80190. dispose(forceDisposeEffect?: boolean): void;
  80191. clone(name: string): TerrainMaterial;
  80192. serialize(): any;
  80193. getClassName(): string;
  80194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80195. }
  80196. }
  80197. declare module BABYLON {
  80198. /** @hidden */
  80199. export var triplanarPixelShader: {
  80200. name: string;
  80201. shader: string;
  80202. };
  80203. }
  80204. declare module BABYLON {
  80205. /** @hidden */
  80206. export var triplanarVertexShader: {
  80207. name: string;
  80208. shader: string;
  80209. };
  80210. }
  80211. declare module BABYLON {
  80212. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80213. mixTexture: BABYLON.BaseTexture;
  80214. private _diffuseTextureX;
  80215. diffuseTextureX: BABYLON.BaseTexture;
  80216. private _diffuseTextureY;
  80217. diffuseTextureY: BABYLON.BaseTexture;
  80218. private _diffuseTextureZ;
  80219. diffuseTextureZ: BABYLON.BaseTexture;
  80220. private _normalTextureX;
  80221. normalTextureX: BABYLON.BaseTexture;
  80222. private _normalTextureY;
  80223. normalTextureY: BABYLON.BaseTexture;
  80224. private _normalTextureZ;
  80225. normalTextureZ: BABYLON.BaseTexture;
  80226. tileSize: number;
  80227. diffuseColor: BABYLON.Color3;
  80228. specularColor: BABYLON.Color3;
  80229. specularPower: number;
  80230. private _disableLighting;
  80231. disableLighting: boolean;
  80232. private _maxSimultaneousLights;
  80233. maxSimultaneousLights: number;
  80234. private _renderId;
  80235. constructor(name: string, scene: BABYLON.Scene);
  80236. needAlphaBlending(): boolean;
  80237. needAlphaTesting(): boolean;
  80238. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80239. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80240. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80241. getAnimatables(): BABYLON.IAnimatable[];
  80242. getActiveTextures(): BABYLON.BaseTexture[];
  80243. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80244. dispose(forceDisposeEffect?: boolean): void;
  80245. clone(name: string): TriPlanarMaterial;
  80246. serialize(): any;
  80247. getClassName(): string;
  80248. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80249. }
  80250. }
  80251. declare module BABYLON {
  80252. /** @hidden */
  80253. export var waterPixelShader: {
  80254. name: string;
  80255. shader: string;
  80256. };
  80257. }
  80258. declare module BABYLON {
  80259. /** @hidden */
  80260. export var waterVertexShader: {
  80261. name: string;
  80262. shader: string;
  80263. };
  80264. }
  80265. declare module BABYLON {
  80266. export class WaterMaterial extends BABYLON.PushMaterial {
  80267. renderTargetSize: BABYLON.Vector2;
  80268. private _bumpTexture;
  80269. bumpTexture: BABYLON.BaseTexture;
  80270. diffuseColor: BABYLON.Color3;
  80271. specularColor: BABYLON.Color3;
  80272. specularPower: number;
  80273. private _disableLighting;
  80274. disableLighting: boolean;
  80275. private _maxSimultaneousLights;
  80276. maxSimultaneousLights: number;
  80277. /**
  80278. * @param {number}: Represents the wind force
  80279. */
  80280. windForce: number;
  80281. /**
  80282. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80283. */
  80284. windDirection: BABYLON.Vector2;
  80285. /**
  80286. * @param {number}: Wave height, represents the height of the waves
  80287. */
  80288. waveHeight: number;
  80289. /**
  80290. * @param {number}: Bump height, represents the bump height related to the bump map
  80291. */
  80292. bumpHeight: number;
  80293. /**
  80294. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80295. */
  80296. private _bumpSuperimpose;
  80297. bumpSuperimpose: boolean;
  80298. /**
  80299. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80300. */
  80301. private _fresnelSeparate;
  80302. fresnelSeparate: boolean;
  80303. /**
  80304. * @param {boolean}: bump Waves modify the reflection.
  80305. */
  80306. private _bumpAffectsReflection;
  80307. bumpAffectsReflection: boolean;
  80308. /**
  80309. * @param {number}: The water color blended with the refraction (near)
  80310. */
  80311. waterColor: BABYLON.Color3;
  80312. /**
  80313. * @param {number}: The blend factor related to the water color
  80314. */
  80315. colorBlendFactor: number;
  80316. /**
  80317. * @param {number}: The water color blended with the reflection (far)
  80318. */
  80319. waterColor2: BABYLON.Color3;
  80320. /**
  80321. * @param {number}: The blend factor related to the water color (reflection, far)
  80322. */
  80323. colorBlendFactor2: number;
  80324. /**
  80325. * @param {number}: Represents the maximum length of a wave
  80326. */
  80327. waveLength: number;
  80328. /**
  80329. * @param {number}: Defines the waves speed
  80330. */
  80331. waveSpeed: number;
  80332. /**
  80333. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80334. * will avoid calculating useless pixels in the pixel shader of the water material.
  80335. */
  80336. disableClipPlane: boolean;
  80337. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80338. private _mesh;
  80339. private _refractionRTT;
  80340. private _reflectionRTT;
  80341. private _reflectionTransform;
  80342. private _lastTime;
  80343. private _lastDeltaTime;
  80344. private _renderId;
  80345. private _useLogarithmicDepth;
  80346. private _waitingRenderList;
  80347. private _imageProcessingConfiguration;
  80348. private _imageProcessingObserver;
  80349. /**
  80350. * Gets a boolean indicating that current material needs to register RTT
  80351. */
  80352. get hasRenderTargetTextures(): boolean;
  80353. /**
  80354. * Constructor
  80355. */
  80356. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80357. get useLogarithmicDepth(): boolean;
  80358. set useLogarithmicDepth(value: boolean);
  80359. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80360. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80361. addToRenderList(node: any): void;
  80362. enableRenderTargets(enable: boolean): void;
  80363. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80364. get renderTargetsEnabled(): boolean;
  80365. needAlphaBlending(): boolean;
  80366. needAlphaTesting(): boolean;
  80367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80370. private _createRenderTargets;
  80371. getAnimatables(): BABYLON.IAnimatable[];
  80372. getActiveTextures(): BABYLON.BaseTexture[];
  80373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80374. dispose(forceDisposeEffect?: boolean): void;
  80375. clone(name: string): WaterMaterial;
  80376. serialize(): any;
  80377. getClassName(): string;
  80378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80379. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80380. }
  80381. }
  80382. declare module BABYLON {
  80383. /** @hidden */
  80384. export var asciiartPixelShader: {
  80385. name: string;
  80386. shader: string;
  80387. };
  80388. }
  80389. declare module BABYLON {
  80390. /**
  80391. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80392. *
  80393. * It basically takes care rendering the font front the given font size to a texture.
  80394. * This is used later on in the postprocess.
  80395. */
  80396. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80397. private _font;
  80398. private _text;
  80399. private _charSize;
  80400. /**
  80401. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80402. */
  80403. get charSize(): number;
  80404. /**
  80405. * Create a new instance of the Ascii Art FontTexture class
  80406. * @param name the name of the texture
  80407. * @param font the font to use, use the W3C CSS notation
  80408. * @param text the caracter set to use in the rendering.
  80409. * @param scene the scene that owns the texture
  80410. */
  80411. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80412. /**
  80413. * Gets the max char width of a font.
  80414. * @param font the font to use, use the W3C CSS notation
  80415. * @return the max char width
  80416. */
  80417. private getFontWidth;
  80418. /**
  80419. * Gets the max char height of a font.
  80420. * @param font the font to use, use the W3C CSS notation
  80421. * @return the max char height
  80422. */
  80423. private getFontHeight;
  80424. /**
  80425. * Clones the current AsciiArtTexture.
  80426. * @return the clone of the texture.
  80427. */
  80428. clone(): AsciiArtFontTexture;
  80429. /**
  80430. * Parses a json object representing the texture and returns an instance of it.
  80431. * @param source the source JSON representation
  80432. * @param scene the scene to create the texture for
  80433. * @return the parsed texture
  80434. */
  80435. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80436. }
  80437. /**
  80438. * Option available in the Ascii Art Post Process.
  80439. */
  80440. export interface IAsciiArtPostProcessOptions {
  80441. /**
  80442. * The font to use following the w3c font definition.
  80443. */
  80444. font?: string;
  80445. /**
  80446. * The character set to use in the postprocess.
  80447. */
  80448. characterSet?: string;
  80449. /**
  80450. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80451. * This number is defined between 0 and 1;
  80452. */
  80453. mixToTile?: number;
  80454. /**
  80455. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80456. * This number is defined between 0 and 1;
  80457. */
  80458. mixToNormal?: number;
  80459. }
  80460. /**
  80461. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80462. *
  80463. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80464. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80465. */
  80466. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80467. /**
  80468. * The font texture used to render the char in the post process.
  80469. */
  80470. private _asciiArtFontTexture;
  80471. /**
  80472. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80473. * This number is defined between 0 and 1;
  80474. */
  80475. mixToTile: number;
  80476. /**
  80477. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80478. * This number is defined between 0 and 1;
  80479. */
  80480. mixToNormal: number;
  80481. /**
  80482. * Instantiates a new Ascii Art Post Process.
  80483. * @param name the name to give to the postprocess
  80484. * @camera the camera to apply the post process to.
  80485. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80486. */
  80487. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80488. }
  80489. }
  80490. declare module BABYLON {
  80491. /** @hidden */
  80492. export var digitalrainPixelShader: {
  80493. name: string;
  80494. shader: string;
  80495. };
  80496. }
  80497. declare module BABYLON {
  80498. /**
  80499. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80500. *
  80501. * It basically takes care rendering the font front the given font size to a texture.
  80502. * This is used later on in the postprocess.
  80503. */
  80504. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80505. private _font;
  80506. private _text;
  80507. private _charSize;
  80508. /**
  80509. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80510. */
  80511. get charSize(): number;
  80512. /**
  80513. * Create a new instance of the Digital Rain FontTexture class
  80514. * @param name the name of the texture
  80515. * @param font the font to use, use the W3C CSS notation
  80516. * @param text the caracter set to use in the rendering.
  80517. * @param scene the scene that owns the texture
  80518. */
  80519. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80520. /**
  80521. * Gets the max char width of a font.
  80522. * @param font the font to use, use the W3C CSS notation
  80523. * @return the max char width
  80524. */
  80525. private getFontWidth;
  80526. /**
  80527. * Gets the max char height of a font.
  80528. * @param font the font to use, use the W3C CSS notation
  80529. * @return the max char height
  80530. */
  80531. private getFontHeight;
  80532. /**
  80533. * Clones the current DigitalRainFontTexture.
  80534. * @return the clone of the texture.
  80535. */
  80536. clone(): DigitalRainFontTexture;
  80537. /**
  80538. * Parses a json object representing the texture and returns an instance of it.
  80539. * @param source the source JSON representation
  80540. * @param scene the scene to create the texture for
  80541. * @return the parsed texture
  80542. */
  80543. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80544. }
  80545. /**
  80546. * Option available in the Digital Rain Post Process.
  80547. */
  80548. export interface IDigitalRainPostProcessOptions {
  80549. /**
  80550. * The font to use following the w3c font definition.
  80551. */
  80552. font?: string;
  80553. /**
  80554. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80555. * This number is defined between 0 and 1;
  80556. */
  80557. mixToTile?: number;
  80558. /**
  80559. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80560. * This number is defined between 0 and 1;
  80561. */
  80562. mixToNormal?: number;
  80563. }
  80564. /**
  80565. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80566. *
  80567. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80568. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80569. */
  80570. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80571. /**
  80572. * The font texture used to render the char in the post process.
  80573. */
  80574. private _digitalRainFontTexture;
  80575. /**
  80576. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80577. * This number is defined between 0 and 1;
  80578. */
  80579. mixToTile: number;
  80580. /**
  80581. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80582. * This number is defined between 0 and 1;
  80583. */
  80584. mixToNormal: number;
  80585. /**
  80586. * Instantiates a new Digital Rain Post Process.
  80587. * @param name the name to give to the postprocess
  80588. * @camera the camera to apply the post process to.
  80589. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80590. */
  80591. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80592. }
  80593. }
  80594. declare module BABYLON {
  80595. /** @hidden */
  80596. export var brickProceduralTexturePixelShader: {
  80597. name: string;
  80598. shader: string;
  80599. };
  80600. }
  80601. declare module BABYLON {
  80602. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80603. private _numberOfBricksHeight;
  80604. private _numberOfBricksWidth;
  80605. private _jointColor;
  80606. private _brickColor;
  80607. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80608. updateShaderUniforms(): void;
  80609. get numberOfBricksHeight(): number;
  80610. set numberOfBricksHeight(value: number);
  80611. get numberOfBricksWidth(): number;
  80612. set numberOfBricksWidth(value: number);
  80613. get jointColor(): BABYLON.Color3;
  80614. set jointColor(value: BABYLON.Color3);
  80615. get brickColor(): BABYLON.Color3;
  80616. set brickColor(value: BABYLON.Color3);
  80617. /**
  80618. * Serializes this brick procedural texture
  80619. * @returns a serialized brick procedural texture object
  80620. */
  80621. serialize(): any;
  80622. /**
  80623. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80624. * @param parsedTexture defines parsed texture data
  80625. * @param scene defines the current scene
  80626. * @param rootUrl defines the root URL containing brick procedural texture information
  80627. * @returns a parsed Brick Procedural BABYLON.Texture
  80628. */
  80629. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80630. }
  80631. }
  80632. declare module BABYLON {
  80633. /** @hidden */
  80634. export var cloudProceduralTexturePixelShader: {
  80635. name: string;
  80636. shader: string;
  80637. };
  80638. }
  80639. declare module BABYLON {
  80640. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80641. private _skyColor;
  80642. private _cloudColor;
  80643. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80644. updateShaderUniforms(): void;
  80645. get skyColor(): BABYLON.Color4;
  80646. set skyColor(value: BABYLON.Color4);
  80647. get cloudColor(): BABYLON.Color4;
  80648. set cloudColor(value: BABYLON.Color4);
  80649. /**
  80650. * Serializes this cloud procedural texture
  80651. * @returns a serialized cloud procedural texture object
  80652. */
  80653. serialize(): any;
  80654. /**
  80655. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80656. * @param parsedTexture defines parsed texture data
  80657. * @param scene defines the current scene
  80658. * @param rootUrl defines the root URL containing cloud procedural texture information
  80659. * @returns a parsed Cloud Procedural BABYLON.Texture
  80660. */
  80661. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80662. }
  80663. }
  80664. declare module BABYLON {
  80665. /** @hidden */
  80666. export var fireProceduralTexturePixelShader: {
  80667. name: string;
  80668. shader: string;
  80669. };
  80670. }
  80671. declare module BABYLON {
  80672. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80673. private _time;
  80674. private _speed;
  80675. private _autoGenerateTime;
  80676. private _fireColors;
  80677. private _alphaThreshold;
  80678. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80679. updateShaderUniforms(): void;
  80680. render(useCameraPostProcess?: boolean): void;
  80681. static get PurpleFireColors(): BABYLON.Color3[];
  80682. static get GreenFireColors(): BABYLON.Color3[];
  80683. static get RedFireColors(): BABYLON.Color3[];
  80684. static get BlueFireColors(): BABYLON.Color3[];
  80685. get autoGenerateTime(): boolean;
  80686. set autoGenerateTime(value: boolean);
  80687. get fireColors(): BABYLON.Color3[];
  80688. set fireColors(value: BABYLON.Color3[]);
  80689. get time(): number;
  80690. set time(value: number);
  80691. get speed(): BABYLON.Vector2;
  80692. set speed(value: BABYLON.Vector2);
  80693. get alphaThreshold(): number;
  80694. set alphaThreshold(value: number);
  80695. /**
  80696. * Serializes this fire procedural texture
  80697. * @returns a serialized fire procedural texture object
  80698. */
  80699. serialize(): any;
  80700. /**
  80701. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80702. * @param parsedTexture defines parsed texture data
  80703. * @param scene defines the current scene
  80704. * @param rootUrl defines the root URL containing fire procedural texture information
  80705. * @returns a parsed Fire Procedural BABYLON.Texture
  80706. */
  80707. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80708. }
  80709. }
  80710. declare module BABYLON {
  80711. /** @hidden */
  80712. export var grassProceduralTexturePixelShader: {
  80713. name: string;
  80714. shader: string;
  80715. };
  80716. }
  80717. declare module BABYLON {
  80718. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80719. private _grassColors;
  80720. private _groundColor;
  80721. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80722. updateShaderUniforms(): void;
  80723. get grassColors(): BABYLON.Color3[];
  80724. set grassColors(value: BABYLON.Color3[]);
  80725. get groundColor(): BABYLON.Color3;
  80726. set groundColor(value: BABYLON.Color3);
  80727. /**
  80728. * Serializes this grass procedural texture
  80729. * @returns a serialized grass procedural texture object
  80730. */
  80731. serialize(): any;
  80732. /**
  80733. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80734. * @param parsedTexture defines parsed texture data
  80735. * @param scene defines the current scene
  80736. * @param rootUrl defines the root URL containing grass procedural texture information
  80737. * @returns a parsed Grass Procedural BABYLON.Texture
  80738. */
  80739. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80740. }
  80741. }
  80742. declare module BABYLON {
  80743. /** @hidden */
  80744. export var marbleProceduralTexturePixelShader: {
  80745. name: string;
  80746. shader: string;
  80747. };
  80748. }
  80749. declare module BABYLON {
  80750. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80751. private _numberOfTilesHeight;
  80752. private _numberOfTilesWidth;
  80753. private _amplitude;
  80754. private _jointColor;
  80755. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80756. updateShaderUniforms(): void;
  80757. get numberOfTilesHeight(): number;
  80758. set numberOfTilesHeight(value: number);
  80759. get amplitude(): number;
  80760. set amplitude(value: number);
  80761. get numberOfTilesWidth(): number;
  80762. set numberOfTilesWidth(value: number);
  80763. get jointColor(): BABYLON.Color3;
  80764. set jointColor(value: BABYLON.Color3);
  80765. /**
  80766. * Serializes this marble procedural texture
  80767. * @returns a serialized marble procedural texture object
  80768. */
  80769. serialize(): any;
  80770. /**
  80771. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80772. * @param parsedTexture defines parsed texture data
  80773. * @param scene defines the current scene
  80774. * @param rootUrl defines the root URL containing marble procedural texture information
  80775. * @returns a parsed Marble Procedural BABYLON.Texture
  80776. */
  80777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80778. }
  80779. }
  80780. declare module BABYLON {
  80781. /** @hidden */
  80782. export var normalMapProceduralTexturePixelShader: {
  80783. name: string;
  80784. shader: string;
  80785. };
  80786. }
  80787. declare module BABYLON {
  80788. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80789. private _baseTexture;
  80790. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80791. updateShaderUniforms(): void;
  80792. render(useCameraPostProcess?: boolean): void;
  80793. resize(size: any, generateMipMaps: any): void;
  80794. get baseTexture(): BABYLON.Texture;
  80795. set baseTexture(texture: BABYLON.Texture);
  80796. /**
  80797. * Serializes this normal map procedural texture
  80798. * @returns a serialized normal map procedural texture object
  80799. */
  80800. serialize(): any;
  80801. /**
  80802. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80803. * @param parsedTexture defines parsed texture data
  80804. * @param scene defines the current scene
  80805. * @param rootUrl defines the root URL containing normal map procedural texture information
  80806. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80807. */
  80808. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80809. }
  80810. }
  80811. declare module BABYLON {
  80812. /** @hidden */
  80813. export var perlinNoiseProceduralTexturePixelShader: {
  80814. name: string;
  80815. shader: string;
  80816. };
  80817. }
  80818. declare module BABYLON {
  80819. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80820. time: number;
  80821. timeScale: number;
  80822. translationSpeed: number;
  80823. private _currentTranslation;
  80824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80825. updateShaderUniforms(): void;
  80826. render(useCameraPostProcess?: boolean): void;
  80827. resize(size: any, generateMipMaps: any): void;
  80828. /**
  80829. * Serializes this perlin noise procedural texture
  80830. * @returns a serialized perlin noise procedural texture object
  80831. */
  80832. serialize(): any;
  80833. /**
  80834. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80835. * @param parsedTexture defines parsed texture data
  80836. * @param scene defines the current scene
  80837. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80838. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80839. */
  80840. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80841. }
  80842. }
  80843. declare module BABYLON {
  80844. /** @hidden */
  80845. export var roadProceduralTexturePixelShader: {
  80846. name: string;
  80847. shader: string;
  80848. };
  80849. }
  80850. declare module BABYLON {
  80851. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80852. private _roadColor;
  80853. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80854. updateShaderUniforms(): void;
  80855. get roadColor(): BABYLON.Color3;
  80856. set roadColor(value: BABYLON.Color3);
  80857. /**
  80858. * Serializes this road procedural texture
  80859. * @returns a serialized road procedural texture object
  80860. */
  80861. serialize(): any;
  80862. /**
  80863. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80864. * @param parsedTexture defines parsed texture data
  80865. * @param scene defines the current scene
  80866. * @param rootUrl defines the root URL containing road procedural texture information
  80867. * @returns a parsed Road Procedural BABYLON.Texture
  80868. */
  80869. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80870. }
  80871. }
  80872. declare module BABYLON {
  80873. /** @hidden */
  80874. export var starfieldProceduralTexturePixelShader: {
  80875. name: string;
  80876. shader: string;
  80877. };
  80878. }
  80879. declare module BABYLON {
  80880. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80881. private _time;
  80882. private _alpha;
  80883. private _beta;
  80884. private _zoom;
  80885. private _formuparam;
  80886. private _stepsize;
  80887. private _tile;
  80888. private _brightness;
  80889. private _darkmatter;
  80890. private _distfading;
  80891. private _saturation;
  80892. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80893. updateShaderUniforms(): void;
  80894. get time(): number;
  80895. set time(value: number);
  80896. get alpha(): number;
  80897. set alpha(value: number);
  80898. get beta(): number;
  80899. set beta(value: number);
  80900. get formuparam(): number;
  80901. set formuparam(value: number);
  80902. get stepsize(): number;
  80903. set stepsize(value: number);
  80904. get zoom(): number;
  80905. set zoom(value: number);
  80906. get tile(): number;
  80907. set tile(value: number);
  80908. get brightness(): number;
  80909. set brightness(value: number);
  80910. get darkmatter(): number;
  80911. set darkmatter(value: number);
  80912. get distfading(): number;
  80913. set distfading(value: number);
  80914. get saturation(): number;
  80915. set saturation(value: number);
  80916. /**
  80917. * Serializes this starfield procedural texture
  80918. * @returns a serialized starfield procedural texture object
  80919. */
  80920. serialize(): any;
  80921. /**
  80922. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80923. * @param parsedTexture defines parsed texture data
  80924. * @param scene defines the current scene
  80925. * @param rootUrl defines the root URL containing startfield procedural texture information
  80926. * @returns a parsed Starfield Procedural BABYLON.Texture
  80927. */
  80928. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80929. }
  80930. }
  80931. declare module BABYLON {
  80932. /** @hidden */
  80933. export var woodProceduralTexturePixelShader: {
  80934. name: string;
  80935. shader: string;
  80936. };
  80937. }
  80938. declare module BABYLON {
  80939. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80940. private _ampScale;
  80941. private _woodColor;
  80942. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80943. updateShaderUniforms(): void;
  80944. get ampScale(): number;
  80945. set ampScale(value: number);
  80946. get woodColor(): BABYLON.Color3;
  80947. set woodColor(value: BABYLON.Color3);
  80948. /**
  80949. * Serializes this wood procedural texture
  80950. * @returns a serialized wood procedural texture object
  80951. */
  80952. serialize(): any;
  80953. /**
  80954. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80955. * @param parsedTexture defines parsed texture data
  80956. * @param scene defines the current scene
  80957. * @param rootUrl defines the root URL containing wood procedural texture information
  80958. * @returns a parsed Wood Procedural BABYLON.Texture
  80959. */
  80960. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80961. }
  80962. }